aloetesting / aloe

Behavior Driven Development using Cucumber for Python
http://aloe.readthedocs.io/
Other
68 stars 17 forks source link

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

Open boechat107 opened 8 years ago

boechat107 commented 8 years ago

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 commented 8 years ago

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

boechat107 commented 8 years ago
python==3.5.1
django==1.9.6
aloe==0.1.8
koterpillar commented 8 years ago

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

boechat107 commented 8 years ago

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

aloe-django==0.1.1
koterpillar commented 8 years ago

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

boechat107 commented 8 years ago
./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 commented 8 years ago

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

boechat107 commented 8 years ago

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