Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Move tests out of kajiki package #70

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ exclude =
per-file-ignores =
# This file uses names from Kajiki's IR language, and confuses
# flake8:
kajiki/tests/test_runtime.py: F821
tests/test_runtime.py: F821
Empty file removed kajiki/tests/data/__init__.py
Empty file.
25 changes: 25 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import importlib
import pathlib
import sys

import pytest


@pytest.fixture(scope="session", autouse=True)
def add_test_data_module():
here = pathlib.Path(__file__).parent
data_package = here / "data" / "__init__.py"
spec = importlib.util.spec_from_file_location("kajiki_test_data", str(data_package))

# TODO(Python3.4): below dance can change to
# importlib.util.module_from_spec() when support for Python 3.4 is
# dropped.
module = type(sys)(spec.name)
module.__name__ = spec.name
module.__loader__ = spec.loader
module.__package__ = spec.parent
module.__path__ = spec.submodule_search_locations
module.__file__ = spec.origin

sys.modules[spec.name] = module
spec.loader.exec_module(module)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion kajiki/tests/test_e2e.py → tests/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@pytest.mark.parametrize(
["args", "golden_file"],
[
(["-p", "kajiki.tests.data.kitchensink"], "kitchensink1.html"),
(["-p", "kajiki_test_data.kitchensink"], "kitchensink1.html"),
([str(DATA / "kitchensink.html")], "kitchensink1.html"),
],
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion kajiki/tests/test_xml.py → tests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ def test_debug(self):
class TestPackageLoader(TestCase):
def test_pkg_loader(self):
loader = PackageLoader()
loader.import_("kajiki.tests.data.debug")
loader.import_("kajiki_test_data.debug")


class TestBuiltinFunctions(TestCase):
Expand Down