From 15e4f636795c48e586a67588a4a64b5a135a1728 Mon Sep 17 00:00:00 2001 From: Abhilash Raj Date: Sat, 5 Aug 2017 19:33:30 -0700 Subject: [PATCH] Fix tests (#15) * Use fixture for the test class. * use scope as function for the fixture. * Run tests in temporary directory. --- papergit/tests/bin/test_commands.py | 5 +++-- papergit/tests/conftest.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/papergit/tests/bin/test_commands.py b/papergit/tests/bin/test_commands.py index d3a697d..9ea0770 100644 --- a/papergit/tests/bin/test_commands.py +++ b/papergit/tests/bin/test_commands.py @@ -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.""" @@ -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() == '' diff --git a/papergit/tests/conftest.py b/papergit/tests/conftest.py index 7177080..632cba5 100644 --- a/papergit/tests/conftest.py +++ b/papergit/tests/conftest.py @@ -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') @@ -29,3 +29,6 @@ def teardown(): print("\nTearing down ...\n") request.addfinalizer(teardown) + + with testing_dir.as_cwd(): + yield