Skip to content

Commit

Permalink
Fix tests (#1571)
Browse files Browse the repository at this point in the history
* Fix plugins test
cleanup a of code

* Try fixing `test_when_animation_is_cached` test

* Lint

* Isort

* Use ascii_lowercase for random strings

* mark test_when_animation_is_cached as xfail

* Fix formatting

* Use tempdir's for doctest also

* Format

* isort

* yield tmpdir
  • Loading branch information
naveen521kk committed May 26, 2021
1 parent 7104d71 commit 6e4b02a
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 163 deletions.
25 changes: 25 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is automatically picked by pytest
# while running tests. So, that each test is
# run on difference temporary directories and avoiding
# errors.

# If it is running Doctest the current directory
# is changed because it also tests the config module
# itself. If it's a normal test then it uses the
# tempconfig to change directories.

import pytest
from _pytest.doctest import DoctestItem

from manim import config, tempconfig


@pytest.fixture(autouse=True)
def temp_media_dir(tmpdir, monkeypatch, request):
if isinstance(request.node, DoctestItem):
monkeypatch.chdir(tmpdir)
yield tmpdir
else:
with tempconfig({"media_dir": str(tmpdir)}):
assert config.media_dir == str(tmpdir)
yield tmpdir
9 changes: 0 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import pytest

from manim import config, tempconfig


def pytest_addoption(parser):
parser.addoption(
Expand Down Expand Up @@ -53,10 +51,3 @@ def reset_cfg_file():
yield
with open(cfgfilepath, "w") as cfgfile:
cfgfile.write(original)


@pytest.fixture(autouse=True)
def temp_media_dir(tmpdir):
with tempconfig({"media_dir": str(tmpdir)}):
assert config.media_dir == str(tmpdir)
yield tmpdir
7 changes: 0 additions & 7 deletions tests/test_plugins/simple_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ def construct(self):
self.play(FadeIn(a))


class NoAllTest(Scene):
def construct(self):
assert "test_plugin" in globals()
a = test_plugin.NoAll()
self.play(FadeIn(a))


class WithAllTest(Scene):
def construct(self):
assert "WithAll" in globals()
Expand Down
Loading

0 comments on commit 6e4b02a

Please sign in to comment.