Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 1.05 KB

5-classes.md

File metadata and controls

42 lines (30 loc) · 1.05 KB

Testing Classes with Fixtures

This assumes you have setup your environment as described in [run_tests.md] and that you are in your virtualenv.

cattery

If you get stuck, take a peek at the solution.

  1. Refactor the Cattery tests in test_cattery.py to use a py.test fixture.

    @pytest.fixture
    def cattery_client():
        ...
    
    def test__add_cats__succeeds(cattery_client):
        ...
  2. Try adding a scope argument to pytest.fixture. What happens when you try setting it to scope, session, or module?

    @pytest.fixture(scope='session')
    def cattery_client():
        ...
  3. When you are done, run your tests:

(catpy)user@host:~/catinabox$ python setup.py test
  1. When the tests run successfully, push them to your pull request:
(catpy)user@host:~/catinabox$ git commit -a
(catpy)user@host:~/catinabox$ git push origin master