| 1 |
from pathlib import Path |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
from pytermgui import FileLoader, JsonLoader, YamlLoader, prettifiers |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
class BaseLoaderTester: |
| 12 |
|
| 13 |
path: Path |
| 14 |
loader: FileLoader |
| 15 |
|
| 16 |
@pytest.fixture(autouse=True) |
| 17 |
def _setup(self): |
| 18 |
self.loader = type(self).loader() |
| 19 |
|
| 20 |
with self.loader as loader, open(self.path) as yaml: |
| 21 |
self.namespace = loader.load(yaml) |
| 22 |
|
| 23 |
def test_namespace_widget_length(self): |
| 24 |
assert len(self.namespace.widgets) == 1 |
| 25 |
|
| 26 |
|
| 27 |
class TestYamlLoader(BaseLoaderTester): |
| 28 |
loader = YamlLoader |
| 29 |
path = Path("tests/test.yaml") |
| 30 |
|
| 31 |
|
| 32 |
class TestJsonLoader(BaseLoaderTester): |
| 33 |
loader = JsonLoader |
| 34 |
path = Path("tests/test.json") |