Prevent tests from creating cachedir tag.
Running test_standarddir would pollute the user's home with `~/.cache/qute_test`. The `no_cachedir_tag` fixture was supposed to prevent this, but was not working because [usefixtures does not work on fixtures] (https://github.com/pytest-dev/pytest/issues/1014). This fixes the fixture to actually prevent cachedir creation, but applies it to tests individually (or by class) rather than with autouse because the cachedir tests cannot pass if it is working.
This commit is contained in:
parent
daaa5ff5c5
commit
1f71520bb2
@ -52,15 +52,15 @@ def no_cachedir_tag(monkeypatch):
|
|||||||
lambda: None)
|
lambda: None)
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture(autouse=True)
|
@pytest.yield_fixture
|
||||||
@pytest.mark.usefixtures('no_cachedir_tag')
|
def reset_standarddir(no_cachedir_tag):
|
||||||
def reset_standarddir():
|
|
||||||
"""Clean up standarddir arguments before and after each test."""
|
"""Clean up standarddir arguments before and after each test."""
|
||||||
standarddir.init(None)
|
standarddir.init(None)
|
||||||
yield
|
yield
|
||||||
standarddir.init(None)
|
standarddir.init(None)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures('reset_standarddir')
|
||||||
@pytest.mark.parametrize('data_subdir, config_subdir, expected', [
|
@pytest.mark.parametrize('data_subdir, config_subdir, expected', [
|
||||||
('foo', 'foo', 'foo/data'),
|
('foo', 'foo', 'foo/data'),
|
||||||
('foo', 'bar', 'foo'),
|
('foo', 'bar', 'foo'),
|
||||||
@ -80,6 +80,7 @@ def test_get_fake_windows_equal_dir(data_subdir, config_subdir, expected,
|
|||||||
assert standarddir.data() == expected
|
assert standarddir.data() == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures('reset_standarddir')
|
||||||
class TestWritableLocation:
|
class TestWritableLocation:
|
||||||
|
|
||||||
"""Tests for _writable_location."""
|
"""Tests for _writable_location."""
|
||||||
@ -100,7 +101,7 @@ class TestWritableLocation:
|
|||||||
assert '\\' in loc
|
assert '\\' in loc
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures('no_cachedir_tag')
|
@pytest.mark.usefixtures('reset_standarddir')
|
||||||
class TestStandardDir:
|
class TestStandardDir:
|
||||||
|
|
||||||
"""Tests for standarddir."""
|
"""Tests for standarddir."""
|
||||||
@ -159,7 +160,7 @@ class TestStandardDir:
|
|||||||
DirArgTest = collections.namedtuple('DirArgTest', 'arg, expected')
|
DirArgTest = collections.namedtuple('DirArgTest', 'arg, expected')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.usefixtures('no_cachedir_tag')
|
@pytest.mark.usefixtures('reset_standarddir')
|
||||||
class TestArguments:
|
class TestArguments:
|
||||||
|
|
||||||
"""Tests with confdir/cachedir/datadir arguments."""
|
"""Tests with confdir/cachedir/datadir arguments."""
|
||||||
@ -274,6 +275,7 @@ class TestInitCacheDirTag:
|
|||||||
assert not tmpdir.listdir()
|
assert not tmpdir.listdir()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures('reset_standarddir')
|
||||||
class TestCreatingDir:
|
class TestCreatingDir:
|
||||||
|
|
||||||
"""Make sure inexistent directories are created properly."""
|
"""Make sure inexistent directories are created properly."""
|
||||||
@ -317,6 +319,7 @@ class TestCreatingDir:
|
|||||||
func()
|
func()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures('reset_standarddir')
|
||||||
class TestSystemData:
|
class TestSystemData:
|
||||||
|
|
||||||
"""Test system data path."""
|
"""Test system data path."""
|
||||||
|
Loading…
Reference in New Issue
Block a user