Skip to content

Commit

Permalink
Don't make a package out of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lysnikolaou committed Feb 4, 2025
1 parent fd368af commit 6dd9edb
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 48 deletions.
Empty file removed tests/__init__.py
Empty file.
9 changes: 5 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pathlib
import pytest

from tests import setup_modules, utils
import setup_modules
import utils


def pytest_configure(config):
Expand Down Expand Up @@ -31,7 +32,7 @@ def pytest_configure(config):
autouse=True
)
def _ext(request):
s, t = request.param
setup, teardown = request.param

constructor_helpers = False
if request.node.get_closest_marker("needs_constructor_helpers") is not None:
Expand All @@ -43,9 +44,9 @@ def _ext(request):
if request.node.get_closest_marker("needs_resolver_helpers") is not None:
resolver_helpers = True

s(constructor_helpers, structure_helpers, resolver_helpers)
setup(constructor_helpers, structure_helpers, resolver_helpers)
yield
t(constructor_helpers, structure_helpers, resolver_helpers)
teardown(constructor_helpers, structure_helpers, resolver_helpers)


@pytest.fixture(autouse=True)
Expand Down
32 changes: 16 additions & 16 deletions tests/data/construct-python-object.data
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
- !!python/object:tests.constructor_helpers.AnObject { foo: 1, bar: two, baz: [3,3,3] }
- !!python/object:tests.constructor_helpers.AnInstance { foo: 1, bar: two, baz: [3,3,3] }
- !!python/object:constructor_helpers.AnObject { foo: 1, bar: two, baz: [3,3,3] }
- !!python/object:constructor_helpers.AnInstance { foo: 1, bar: two, baz: [3,3,3] }

- !!python/object/new:tests.constructor_helpers.AnObject { args: [1, two], kwds: {baz: [3,3,3]} }
- !!python/object/apply:tests.constructor_helpers.AnInstance { args: [1, two], kwds: {baz: [3,3,3]} }
- !!python/object/new:constructor_helpers.AnObject { args: [1, two], kwds: {baz: [3,3,3]} }
- !!python/object/apply:constructor_helpers.AnInstance { args: [1, two], kwds: {baz: [3,3,3]} }

- !!python/object:tests.constructor_helpers.AState { _foo: 1, _bar: two, _baz: [3,3,3] }
- !!python/object/new:tests.constructor_helpers.ACustomState { state: !!python/tuple [1, two, [3,3,3]] }
- !!python/object:constructor_helpers.AState { _foo: 1, _bar: two, _baz: [3,3,3] }
- !!python/object/new:constructor_helpers.ACustomState { state: !!python/tuple [1, two, [3,3,3]] }

- !!python/object/new:tests.constructor_helpers.InitArgs [1, two, [3,3,3]]
- !!python/object/new:tests.constructor_helpers.InitArgsWithState { args: [1, two], state: [3,3,3] }
- !!python/object/new:constructor_helpers.InitArgs [1, two, [3,3,3]]
- !!python/object/new:constructor_helpers.InitArgsWithState { args: [1, two], state: [3,3,3] }

- !!python/object/new:tests.constructor_helpers.NewArgs [1, two, [3,3,3]]
- !!python/object/new:tests.constructor_helpers.NewArgsWithState { args: [1, two], state: [3,3,3] }
- !!python/object/new:constructor_helpers.NewArgs [1, two, [3,3,3]]
- !!python/object/new:constructor_helpers.NewArgsWithState { args: [1, two], state: [3,3,3] }

- !!python/object/apply:tests.constructor_helpers.Reduce [1, two, [3,3,3]]
- !!python/object/apply:tests.constructor_helpers.ReduceWithState { args: [1, two], state: [3,3,3] }
- !!python/object/apply:constructor_helpers.Reduce [1, two, [3,3,3]]
- !!python/object/apply:constructor_helpers.ReduceWithState { args: [1, two], state: [3,3,3] }

- !!python/object/new:tests.constructor_helpers.Slots { state: !!python/tuple [null, { foo: 1, bar: 'two', baz: [3,3,3] } ] }
- !!python/object/new:constructor_helpers.Slots { state: !!python/tuple [null, { foo: 1, bar: 'two', baz: [3,3,3] } ] }

- !!python/object/new:tests.constructor_helpers.MyInt [3]
- !!python/object/new:tests.constructor_helpers.MyList { listitems: [~, ~, ~] }
- !!python/object/new:tests.constructor_helpers.MyDict { dictitems: {0, 1, 2} }
- !!python/object/new:constructor_helpers.MyInt [3]
- !!python/object/new:constructor_helpers.MyList { listitems: [~, ~, ~] }
- !!python/object/new:constructor_helpers.MyDict { dictitems: {0, 1, 2} }
6 changes: 3 additions & 3 deletions tests/setup_modules.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import yaml

from tests.constructor_helpers import make_constructor_helpers
from tests.resolver_helpers import make_resolver_helpers
from tests.structure_helpers import make_structure_helpers
from constructor_helpers import make_constructor_helpers
from resolver_helpers import make_resolver_helpers
from structure_helpers import make_structure_helpers


RUNNING_C_EXT = False
Expand Down
2 changes: 1 addition & 1 deletion tests/structure_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import yaml
import tests.canonical # Needed for CanonicalLoader
import canonical # Needed for CanonicalLoader


def make_structure_helpers():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_canonical.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

import yaml
import tests.canonical
from tests.utils import filter_data_files
import canonical
from utils import filter_data_files


@pytest.mark.parametrize("canonical_filename", filter_data_files(".canonical"))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import yaml
import yaml.tokens
from tests.utils import filter_data_files, load_code, serialize_value
from utils import filter_data_files, load_code, serialize_value


@pytest.mark.needs_constructor_helpers
Expand All @@ -11,7 +11,7 @@ def test_constructor_types(data_filename, code_filename):
import datetime
import signal

from tests.constructor_helpers import (
from constructor_helpers import (
MyLoader, MyTestClass1, FixedOffset, MyTestClass2, MyTestClass3, YAMLObject1, AnObject,
AnInstance, AState, ACustomState, InitArgs, InitArgsWithState, NewArgs, NewArgsWithState,
Reduce, ReduceWithState, Slots, MyInt, MyList, MyDict,
Expand All @@ -36,7 +36,7 @@ def test_constructor_types(data_filename, code_filename):
@pytest.mark.needs_constructor_helpers
@pytest.mark.parametrize("data_filename", filter_data_files(".subclass_blacklist"))
def test_subclass_blacklist_types(data_filename):
from tests.constructor_helpers import MyFullLoader
from constructor_helpers import MyFullLoader

with pytest.raises(yaml.YAMLError):
with open(data_filename, 'rb') as file:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_emitter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files

def _compare_events(events1, events2):
assert len(events1) == len(events2), (events1, events2)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_errors.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

import yaml
from tests import test_emitter
from tests.utils import filter_data_files
import test_emitter
from utils import filter_data_files

@pytest.mark.parametrize("error_filename", filter_data_files(".loader-error"))
def test_loader_error(error_filename):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_input_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files


@pytest.mark.parametrize("unicode_filename", filter_data_files(".unicode"))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mark.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files


@pytest.mark.parametrize("marks_filename", filter_data_files(".marks"))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_multi_constructor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import yaml
from tests.utils import filter_data_files, load_code
from utils import filter_data_files, load_code


def myconstructor1(constructor, tag, node):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_reader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import yaml.reader
from tests.utils import filter_data_files
from utils import filter_data_files

def _run_reader(data):
with pytest.raises(yaml.reader.ReaderError):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_recursive.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files

class AnInstance:

Expand Down
4 changes: 2 additions & 2 deletions tests/test_representer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from tests.utils import filter_data_files, load_code, serialize_value
from utils import filter_data_files, load_code, serialize_value


@pytest.mark.needs_constructor_helpers
Expand All @@ -10,7 +10,7 @@ def test_representer_types(code_filename):
import datetime
import signal

from tests.constructor_helpers import (
from constructor_helpers import (
MyDumper, MyLoader, FixedOffset, AnObject, AnInstance, AState, today, MyTestClass1,
ACustomState, MyTestClass2, InitArgs, MyTestClass3, InitArgsWithState, YAMLObject1,
NewArgs, NewArgsWithState, Reduce, ReduceWithState, Slots, MyInt, MyList, MyDict
Expand Down
6 changes: 3 additions & 3 deletions tests/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files


@pytest.mark.parametrize("data_filename,detect_filename", filter_data_files(".data", ".detect"))
Expand Down Expand Up @@ -38,7 +38,7 @@ def _convert_node(node):
@pytest.mark.needs_resolver_helpers
@pytest.mark.parametrize("data_filename,path_filename", filter_data_files(".data", ".path"))
def test_path_resolver_loader(data_filename, path_filename):
from tests.resolver_helpers import MyLoader
from resolver_helpers import MyLoader

with open(data_filename, 'rb') as file:
nodes1 = list(yaml.compose_all(file.read(), Loader=MyLoader))
Expand All @@ -53,7 +53,7 @@ def test_path_resolver_loader(data_filename, path_filename):
@pytest.mark.needs_resolver_helpers
@pytest.mark.parametrize("data_filename,path_filename", filter_data_files(".data", ".path"))
def test_path_resolver_dumper(data_filename, path_filename):
from tests.resolver_helpers import MyDumper
from resolver_helpers import MyDumper

for filename in [data_filename, path_filename]:
with open(filename, 'rb') as file:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files


def check_bool(value, expected):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sort_keys.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files

@pytest.mark.parametrize("input_filename,sorted_filename", filter_data_files(".sort", ".sorted"))
def test_sort_keys(input_filename, sorted_filename):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files


def _convert_structure(loader):
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_composer(data_filename, canonical_filename):
@pytest.mark.needs_structure_helpers
@pytest.mark.parametrize("data_filename,canonical_filename", filter_data_files('.data', '.canonical'))
def test_constructor(data_filename, canonical_filename):
from tests.structure_helpers import MyLoader, MyCanonicalLoader
from structure_helpers import MyLoader, MyCanonicalLoader

native1 = None
native2 = None
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files

# Tokens mnemonic:
# directive: %
Expand Down
2 changes: 1 addition & 1 deletion tests/test_yaml_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest

import yaml
from tests.utils import filter_data_files
from utils import filter_data_files


@pytest.mark.c_only
Expand Down

0 comments on commit 6dd9edb

Please sign in to comment.