Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to test threads with async topic? #128

Open
aldefalco opened this issue Sep 23, 2015 · 2 comments
Open

Is it possible to test threads with async topic? #128

aldefalco opened this issue Sep 23, 2015 · 2 comments

Comments

@aldefalco
Copy link

I tried to test following:

from pyvows import Vows, expect
from threading import Thread
from time import sleep

class MyThread(Thread):

    def __init__(self, a, b, done):
        super(MyThread, self).__init__()
        self.a = a
        self.b = b
        self.done = done

    def run(self):
        while True:
            sleep(2)
            self.done(self.a+self.b)
            break

def sum_in_thread(a, b, callback):
    t = MyThread(a, b, callback)
    t.start()

def sum(a, b, callback):
    callback(a+b)

@Vows.batch
class ThreadContext(Vows.Context):
    @Vows.async_topic
    def topic(self, callback):
        sum_in_thread(2,2, callback)
        #sum(2,2, callback)

    def should_equal_to_4(self, topic):
        expect(topic[0]).to_equal(4)

It passed but with 0 honored. Is it possible to test this case?

@heynemann
Copy link
Owner

I don't think so... ;(

@aldefalco
Copy link
Author

Ah, I think the problem is a joining main thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants