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

@before.all runs before the testing database is created #118

Open
boechat107 opened this issue Aug 24, 2016 · 8 comments
Open

@before.all runs before the testing database is created #118

boechat107 opened this issue Aug 24, 2016 · 8 comments

Comments

@boechat107
Copy link

boechat107 commented Aug 24, 2016

Hey, guys!

I used the decorator @before.all, but I noticed that my function ran even before the creation of the test database, writing data into my real database.

Is this the expected behavior?

This is a great library, by the way! ;-)

@koterpillar
Copy link
Member

This is not right. What versions of Aloe, Aloe-Django, Django and Python are you using?

@boechat107
Copy link
Author

python==3.5.1
django==1.9.6
aloe==0.1.8

@koterpillar
Copy link
Member

Did you install https://aloe.readthedocs.org/projects/aloe-django ?

@boechat107
Copy link
Author

boechat107 commented Aug 24, 2016

Ah, yes, I did. I'm sorry, I forgot to mention it before.

aloe-django==0.1.1

@koterpillar
Copy link
Member

Please make the callback raise an exception, and paste the resulting traceback.

@boechat107
Copy link
Author

./manage.py harvest directory/features/user_create_normal_account.feature
nosetests directory/features/user_create_normal_account.feature --verbosity=1
Creating test database for alias 'default'...
E
======================================================================
ERROR: Failure: Exception ()
    ----------------------------------------------------------------------
    Traceback (most recent call last):
          File "/usr/local/lib/python3.5/site-packages/nose/failure.py", line 39, in
          runTest
              raise self.exc_val.with_traceback(self.tb)
            File "/usr/local/lib/python3.5/site-packages/nose/plugins/manager.py",
          line 154, in generate
              for r in result:
            File "/usr/local/lib/python3.5/site-packages/aloe/plugin.py", line 204,
            in loadTestsFromFile
              self.ensure_before_callbacks()
            File "/usr/local/lib/python3.5/site-packages/aloe/plugin.py", line 225,
            in ensure_before_callbacks
              before_all()
            File "/usr/local/lib/python3.5/site-packages/aloe/registry.py", line 186,
            in before_func
              before_hook(*args, **kwargs)
            File "/work/royalty_exchange_project/directory/features/browser.py", line
          67, in before_all_test
              raise Exception()
          Exception

          ----------------------------------------------------------------------
          Ran 1 test in 0.001s

          FAILED (errors=1)
    Destroying test database for alias 'default'...

I tried to use this hook to create a test user and I noticed that the user was been added to my
default database.

@koterpillar
Copy link
Member

Confirmed here - running just harvest works, specifying a feature file breaks.

@boechat107
Copy link
Author

Uh, OK, I didn't notice this difference, since I always specify the feature files. Thanks for investigating it!

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