refactor: move 'example_' scripts out of repo root (#288)

This commit is contained in:
Jonathon Belotti
2023-04-24 17:57:20 -04:00
committed by GitHub
parent b303477a2a
commit 220062262e
7 changed files with 22 additions and 7 deletions

View File

@@ -25,4 +25,4 @@ jobs:
- name: Run deployment script
run: |
python3 example_deploy.py --no-dry-run
python3 internal/deploy.py --no-dry-run

View File

@@ -66,7 +66,7 @@ jobs:
run: pip install mypy==0.950
- name: Run
run: python3 example_mypy.py
run: python3 internal/typecheck.py
pytest:
name: Pytest

View File

@@ -6,7 +6,7 @@ import sys
from pathlib import Path
from typing import NamedTuple, Optional
from example_utils import ExampleType, get_examples
from utils import ExampleType, get_examples
class DeployError(NamedTuple):

View File

@@ -1,9 +1,12 @@
import importlib
import json
import pathlib
import sys
import pytest
from example_utils import (
from utils import (
DEFAULT_DIRECTORY,
ExampleType,
get_examples,
get_examples_json,
@@ -14,6 +17,13 @@ examples = [ex for ex in get_examples() if ex.type == ExampleType.MODULE]
example_ids = [ex.module for ex in examples]
@pytest.fixture(autouse=False)
def add_root_to_syspath(monkeypatch):
sys.path.append(str(DEFAULT_DIRECTORY))
yield
sys.path.pop()
@pytest.mark.parametrize("example", examples, ids=example_ids)
def test_filename(example):
assert not example.repo_filename.startswith("/")
@@ -21,7 +31,7 @@ def test_filename(example):
@pytest.mark.parametrize("example", examples, ids=example_ids)
def test_import(example):
def test_import(example, add_root_to_syspath):
importlib.import_module(example.module)

3
internal/readme.md Normal file
View File

@@ -0,0 +1,3 @@
### `Internal/`
This is internal repository and documentation management code. It does not contain examples.

View File

@@ -6,7 +6,7 @@ from enum import Enum
from pathlib import Path
from typing import Iterator, Optional
DEFAULT_DIRECTORY = Path(__file__).parent
DEFAULT_DIRECTORY = Path(__file__).parent.parent
with warnings.catch_warnings():
@@ -136,7 +136,9 @@ def get_examples(
for subdir in sorted(
p
for p in directory.iterdir()
if p.is_dir() and not p.name.startswith(".")
if p.is_dir()
and not p.name.startswith(".")
and not p.name.startswith("internal")
):
yield from gather_example_files(
parents=[], subdir=subdir, ignored=ignored, recurse=True