Skip to content

Commit

Permalink
Fix tests (#15)
Browse files Browse the repository at this point in the history
* Use fixture for the test class.

* use scope as function for the fixture.

* Run tests in temporary directory.
  • Loading branch information
maxking authored Aug 6, 2017
1 parent e445ed0 commit 15e4f63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions papergit/tests/bin/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from papergit.bin.paper_git import main


@pytest.mark.usefixtures('initialize_fixture')
class TestPaperGitCommand(object):
"""Tests for the main paper-git command."""

Expand Down Expand Up @@ -36,5 +37,5 @@ def test_initialization(self):
with patch('sys.argv', testargs), \
patch('sys.stdout', output), patch('sys.stderr', error):
main()
assert '' in output.getvalue()
assert '' in error.getvalue()
assert output.getvalue() == ''
assert error.getvalue() == ''
5 changes: 4 additions & 1 deletion papergit/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
""")


@pytest.fixture(scope="session")
@pytest.fixture
def initialize_fixture(tmpdir_factory, request):
print("\nInitializing tests ...\n")
testing_dir = tmpdir_factory.mktemp('var')
Expand All @@ -29,3 +29,6 @@ def teardown():
print("\nTearing down ...\n")

request.addfinalizer(teardown)

with testing_dir.as_cwd():
yield

0 comments on commit 15e4f63

Please sign in to comment.