Skip to content

Commit d13ee37

Browse files
committed
fix(tests): remove import conftest
Importing from conftest caused an ImportError in test_cli.py, when the second conftest.py is created. conftest.py is a pytest magic module, it is most commonly used for defining fixtures. The fixtures defined there are made available to tests via dependency injection in parameters, not via importing them. TestHandler was moved to tests/test_cli.py from tests/conftest.py
1 parent 9c4b792 commit d13ee37

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

tests/conftest.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,13 @@
22

33
import pytest
44

5-
from unblob.extractors import Command
6-
from unblob.models import Handler, HexString, Task, TaskResult
5+
from unblob.models import Task, TaskResult
76
from unblob.testing import ( # noqa: F401 (module imported but unused)
87
configure_logging,
98
extraction_config,
109
)
1110

1211

13-
class TestHandler(Handler):
14-
NAME = "test_handler"
15-
PATTERNS = [HexString("21 3C")]
16-
EXTRACTOR = Command("testcommand", "for", "test", "handler")
17-
18-
def calculate_chunk(self, *args, **kwargs):
19-
pass
20-
21-
2212
@pytest.fixture
2313
def task_result():
2414
task = Task(Path("/nonexistent"), 0)

tests/test_cli.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44

55
import pytest
66
from click.testing import CliRunner
7-
from conftest import TestHandler
87

98
import unblob.cli
109
from unblob.extractors import Command
1110
from unblob.handlers import BUILTIN_HANDLERS
11+
from unblob.models import Handler, HexString
1212
from unblob.processing import DEFAULT_DEPTH, DEFAULT_PROCESS_NUM, ExtractionConfig
1313

1414

15+
class TestHandler(Handler):
16+
NAME = "test_handler"
17+
PATTERNS = [HexString("21 3C")]
18+
EXTRACTOR = Command("testcommand", "for", "test", "handler")
19+
20+
def calculate_chunk(self, *args, **kwargs):
21+
pass
22+
23+
1524
class ExistingCommandHandler(TestHandler):
1625
EXTRACTOR = Command("sh", "something")
1726

0 commit comments

Comments
 (0)