Skip to content

Commit 298a8b6

Browse files
committed
Test: Fix pytest collect in root
Signed-off-by: Jos Verlinde <[email protected]>
1 parent 0da8855 commit 298a8b6

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

tests/createstubs/conftest.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,5 @@
44

55
UName = namedtuple("UName", ["sysname", "nodename", "release", "version", "machine"])
66

7-
LOCATIONS = ["board", pytest.param("minified", marks=pytest.mark.minified)]
8-
VARIANTS = ["createstubs", "createstubs_mem", "createstubs_db"]
97

108

11-
def import_variant(location: str, variant: str, minified: bool = False):
12-
# sourcery skip: assign-if-exp
13-
"""Import the variant module and return it."""
14-
if location == "minified":
15-
minified = True
16-
if minified:
17-
mod_name = f".board.{variant}_min"
18-
else:
19-
mod_name = f".board.{variant}"
20-
return import_module(mod_name, "stubber") # type: ignore

tests/createstubs/createstubs_all_test.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
except ModuleNotFoundError:
1616
import tomli as tomllib
1717

18-
from conftest import LOCATIONS, VARIANTS, import_variant
18+
from shared import LOCATIONS, VARIANTS, import_variant
1919

2020
pytestmark = pytest.mark.micropython
2121

@@ -73,8 +73,9 @@ def test_stubber_Class_available(
7373

7474
@pytest.mark.parametrize("variant", VARIANTS)
7575
@pytest.mark.parametrize("location", LOCATIONS)
76-
def test_stubber_info_basic(location: Any, variant: str, mock_micropython_path: Generator[str, None, None]):
77-
76+
def test_stubber_info_basic(
77+
location: Any, variant: str, mock_micropython_path: Generator[str, None, None]
78+
):
7879
createstubs = import_variant(location, variant)
7980
stubber = createstubs.Stubber()
8081
assert stubber is not None, "Can't create Stubber instance"
@@ -94,7 +95,10 @@ def test_stubber_info_basic(location: Any, variant: str, mock_micropython_path:
9495
@pytest.mark.parametrize("variant", VARIANTS)
9596
@pytest.mark.parametrize("location", LOCATIONS)
9697
def test_stubber_info_custom(
97-
location: Any, variant: str, fx_add_minified_path: Generator[str, None, None], mock_micropython_path: Generator[str, None, None]
98+
location: Any,
99+
variant: str,
100+
fx_add_minified_path: Generator[str, None, None],
101+
mock_micropython_path: Generator[str, None, None],
98102
):
99103
createstubs = import_variant(location, variant)
100104

tests/createstubs/literal_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
except ModuleNotFoundError:
1717
import tomli as tomllib
1818

19-
from conftest import LOCATIONS, VARIANTS, import_variant
19+
from shared import LOCATIONS, VARIANTS, import_variant
2020

2121
pytestmark = pytest.mark.micropython
2222

tests/createstubs/shared.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import pytest
2+
3+
LOCATIONS = ["board", pytest.param("minified", marks=pytest.mark.minified)]
4+
VARIANTS = ["createstubs", "createstubs_mem", "createstubs_db"]
5+
6+
7+
def import_variant(location: str, variant: str, minified: bool = False):
8+
# sourcery skip: assign-if-exp
9+
"""Import the variant module and return it."""
10+
if location == "minified":
11+
minified = True
12+
if minified:
13+
mod_name = f".board.{variant}_min"
14+
else:
15+
mod_name = f".board.{variant}"
16+
return import_module(mod_name, "stubber") # type: ignore

0 commit comments

Comments
 (0)