tests/functional2: Fix Python LSP by adjusting imports
See: cl/4840
When importing Python modules, we include `functional2` in the module
path, like this:
from functional2.testlib.fixtures.env import ManagedEnv
This means that python expects to see a file like
`functional2/testlib/fixtures/env.py`. We run `pytest` from `tests/` in
the `justfile` and have `tests/functional2/__init__.py` so `pytest` in
`meson` is able to find these imports.
However, language servers generally consider the `pyproject.toml` to be
the project root, so (e.g.) `pyright` is unable to follow any of the
`functional2` imports, leading to lots of spurious errors.
In cl/4840 I moved `tests/functional2/pyproject.toml` to
`tests/pyproject.toml`, which worked but was considered aesthetically
unappealing.
This diff is much larger but it's a more elegant solution.
Change-Id: I2983c7b87f88f59a4e3521451a9f5acd6a6a6964
This commit is contained in:
@@ -43,7 +43,7 @@ test-integration *OPTIONS: install (test "--suite" "installcheck")
|
||||
|
||||
# Run functional2 tests using pytest directly, allowing for additional arguments to be passed to pytest e.g. for more granular test selection
|
||||
test-functional2 *OPTIONS:
|
||||
cd tests && python -m pytest -v {{ OPTIONS }} functional2
|
||||
cd tests/functional2 && python -m pytest -v {{ OPTIONS }}
|
||||
|
||||
alias clang-tidy := lint
|
||||
|
||||
|
||||
@@ -20,9 +20,6 @@ respect-gitignore = true
|
||||
# show what violations have been fixed
|
||||
show-fixes = true
|
||||
|
||||
# need to test if "." or ".." is correct, as we assume functional2 to be the root directory for imports
|
||||
src = [".."]
|
||||
|
||||
[tool.ruff.lint]
|
||||
|
||||
preview = true
|
||||
|
||||
@@ -47,7 +47,7 @@ Additional testing resources like a temporary directory, asset files, nix comman
|
||||
To check if something equals or a condition is true, use the `assert` expression:
|
||||
|
||||
```python
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
# Trivial test
|
||||
def test_example():
|
||||
@@ -128,7 +128,7 @@ Injecting parameters into a test that are controlled by [fixtures](#useful-fixtu
|
||||
This is currently only used by the `pytest_command` fixture, to test our framework.
|
||||
```python
|
||||
import pytest
|
||||
from functional2.testlib.fixtures.pytest_command import Command
|
||||
from testlib.fixtures.pytest_command import Command
|
||||
@pytest.mark.parametrize("pytest_command",
|
||||
[
|
||||
["-k", "fun"],
|
||||
@@ -188,7 +188,7 @@ In order to make its usage easier, one can also use this fixture by using our cu
|
||||
```python
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from functional2.testlib.fixtures.file_helper import File, Symlink, with_files
|
||||
from testlib.fixtures.file_helper import File, Symlink, with_files
|
||||
|
||||
@with_files(
|
||||
{
|
||||
@@ -203,7 +203,7 @@ To run a function twice with a different set of files, one can pass multiple dic
|
||||
|
||||
```python
|
||||
from pathlib import Path
|
||||
from functional2.testlib.fixtures.file_helper import File, with_files
|
||||
from testlib.fixtures.file_helper import File, with_files
|
||||
|
||||
|
||||
@with_files(
|
||||
@@ -226,7 +226,7 @@ In order for the golden values to actually update within the code base (compared
|
||||
|
||||
```python
|
||||
import pytest
|
||||
from functional2.testlib.fixtures.file_helper import AssetSymlink, with_files
|
||||
from testlib.fixtures.file_helper import AssetSymlink, with_files
|
||||
|
||||
|
||||
@with_files(
|
||||
@@ -243,7 +243,7 @@ def test_example(snapshot):
|
||||
An object which provides nix executables.
|
||||
|
||||
```python
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
# Simple test that runs `nix-instantiate` with some arguments and checks its output
|
||||
def test_err_context(nix: Nix):
|
||||
|
||||
@@ -4,10 +4,10 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.fixtures.file_helper import with_files
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset_pack
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.file_helper import with_files
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset_pack
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
@@ -4,10 +4,10 @@ import textwrap
|
||||
from urllib.parse import urlencode, quote
|
||||
import sys
|
||||
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.file_helper import with_files
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.file_helper import with_files
|
||||
from testlib.utils import get_global_asset
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@@ -2,10 +2,10 @@ import sys
|
||||
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
from functional2.testlib.fixtures.file_helper import with_files
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset, CopyFile
|
||||
from functional2.testlib.xattrs import verify_no_xattrs_in_tree, skip_if_xattrs_are_unsupported
|
||||
from testlib.fixtures.file_helper import with_files
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset, CopyFile
|
||||
from testlib.xattrs import verify_no_xattrs_in_tree, skip_if_xattrs_are_unsupported
|
||||
|
||||
|
||||
@with_files(
|
||||
|
||||
@@ -3,8 +3,8 @@ from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import File, with_files, EnvTemplate
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.file_helper import File, with_files, EnvTemplate
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
files = {
|
||||
"dep": {"flake.nix": File("{outputs = i: { };}")},
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import re
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset
|
||||
|
||||
_fod_files = {
|
||||
"fod-failing.nix": CopyFile("assets/test_build/fod-failing.nix"),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset
|
||||
|
||||
|
||||
_mo_files = {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset_pack
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset_pack
|
||||
|
||||
_files = {
|
||||
"output-cycles.nix": CopyFile("assets/test_build/output-cycles.nix"),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from functional2.testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset_pack
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset_pack
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ from pathlib import Path
|
||||
import pytest
|
||||
from _pytest.fixtures import FixtureRequest
|
||||
|
||||
from functional2.testlib.fixtures.command import Command
|
||||
from functional2.testlib.fixtures.file_helper import with_files, Symlink, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset_pack, get_global_asset
|
||||
from testlib.fixtures.command import Command
|
||||
from testlib.fixtures.file_helper import with_files, Symlink, CopyFile
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset_pack, get_global_asset
|
||||
|
||||
|
||||
TAR_FILES = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from functional2.testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset
|
||||
|
||||
_files = {
|
||||
"timeout.nix": CopyFile("assets/test_timeout/timeout.nix"),
|
||||
|
||||
@@ -4,8 +4,8 @@ import pytest
|
||||
import signal
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
COMMANDS = ["copy-closure", "collect-garbage"]
|
||||
|
||||
|
||||
@@ -3,15 +3,10 @@ from collections.abc import Callable
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import (
|
||||
_init_files,
|
||||
File,
|
||||
AssetSymlink,
|
||||
with_files,
|
||||
Symlink,
|
||||
)
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from testlib.fixtures.file_helper import _init_files # noqa: PLC2701
|
||||
from testlib.fixtures.file_helper import File, AssetSymlink, with_files, Symlink
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
|
||||
|
||||
@pytest.mark.parametrize("algo", ["md5", "sha1", "sha256", "sha512"])
|
||||
|
||||
@@ -3,9 +3,9 @@ import re
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import CopyFile, with_files
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
from testlib.fixtures.file_helper import CopyFile, with_files
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset
|
||||
|
||||
_files = {
|
||||
"search.nix": CopyFile("assets/test_search/search.nix"),
|
||||
|
||||
@@ -2,9 +2,9 @@ import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset
|
||||
|
||||
_mo_files = {"config.nix": get_global_asset("config.nix"), "drv.nix": CopyFile("assets/drv.nix")}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from functional2.testlib.fixtures.file_helper import with_files
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset_pack
|
||||
from testlib.fixtures.file_helper import with_files
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset_pack
|
||||
|
||||
|
||||
@with_files(get_global_asset_pack("dependencies"))
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
pytest_plugins = (
|
||||
"functional2.testlib.fixtures.env",
|
||||
"functional2.testlib.fixtures.formatter",
|
||||
"functional2.testlib.fixtures.file_helper",
|
||||
"functional2.testlib.fixtures.logger",
|
||||
"functional2.testlib.fixtures.command",
|
||||
"functional2.testlib.fixtures.nix",
|
||||
"functional2.testlib.fixtures.snapshot",
|
||||
"functional2.testlib.fixtures.pytest_command",
|
||||
"testlib.fixtures.env",
|
||||
"testlib.fixtures.formatter",
|
||||
"testlib.fixtures.file_helper",
|
||||
"testlib.fixtures.logger",
|
||||
"testlib.fixtures.command",
|
||||
"testlib.fixtures.nix",
|
||||
"testlib.fixtures.snapshot",
|
||||
"testlib.fixtures.pytest_command",
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
import json
|
||||
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
import pytest
|
||||
from typing import NamedTuple
|
||||
from textwrap import dedent
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import re
|
||||
from textwrap import dedent
|
||||
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
def test_regression_9932(nix: Nix):
|
||||
|
||||
@@ -3,8 +3,8 @@ from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, CopyFile, Symlink, File
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile, Symlink, File
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
def test_trivial_addition(nix: Nix):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
# ruff: noqa: N802
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.fixtures.file_helper import with_files
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.file_helper import with_files
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset
|
||||
|
||||
|
||||
@with_files({"trivial.nix": get_global_asset("trivial.nix")})
|
||||
|
||||
@@ -2,9 +2,9 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, File, CopyFile
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset
|
||||
from testlib.fixtures.file_helper import with_files, File, CopyFile
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset
|
||||
|
||||
|
||||
use_impure_message = "is forbidden in pure eval mode (use '--impure' to override)"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, File, AssetSymlink, Symlink
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from testlib.fixtures.file_helper import with_files, File, AssetSymlink, Symlink
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
|
||||
|
||||
@with_files(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from logging import Logger
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
import re
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from logging import Logger
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
import re
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from pathlib import Path
|
||||
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.file_helper import CopyFile, Symlink, with_files, File
|
||||
from functional2.testlib.utils import get_global_asset_pack
|
||||
from functional2.testlib.fixtures.command import Command
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.file_helper import CopyFile, Symlink, with_files, File
|
||||
from testlib.utils import get_global_asset_pack
|
||||
from testlib.fixtures.command import Command
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
|
||||
|
||||
@with_files(
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from functional2.lang.test_lang import test_eval_okay as nix_eval
|
||||
from functional2.testlib.fixtures.file_helper import with_files, File, AssetSymlink
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from lang.test_lang import test_eval_okay as nix_eval
|
||||
from testlib.fixtures.file_helper import with_files, File, AssetSymlink
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
|
||||
|
||||
@with_files(
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
from pathlib import Path
|
||||
from collections.abc import Callable
|
||||
|
||||
from functional2.lang.test_lang import test_eval_okay as nix_eval
|
||||
from functional2.testlib.fixtures.file_helper import (
|
||||
with_files,
|
||||
CopyFile,
|
||||
AssetSymlink,
|
||||
File,
|
||||
Symlink,
|
||||
)
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from lang.test_lang import test_eval_okay as nix_eval
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile, AssetSymlink, File, Symlink
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
|
||||
|
||||
@with_files(
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from functional2.lang.test_lang import test_eval_okay as nix_eval
|
||||
from functional2.testlib.fixtures.file_helper import (
|
||||
with_files,
|
||||
CopyFile,
|
||||
Symlink,
|
||||
AssetSymlink,
|
||||
File,
|
||||
)
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from lang.test_lang import test_eval_okay as nix_eval
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile, Symlink, AssetSymlink, File
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
|
||||
|
||||
@with_files(
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from functional2.lang.test_lang import test_eval_okay as nix_eval
|
||||
from functional2.testlib.fixtures.file_helper import (
|
||||
with_files,
|
||||
CopyFile,
|
||||
Symlink,
|
||||
AssetSymlink,
|
||||
File,
|
||||
)
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from lang.test_lang import test_eval_okay as nix_eval
|
||||
from testlib.fixtures.file_helper import with_files, CopyFile, Symlink, AssetSymlink, File
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
|
||||
|
||||
@with_files(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
def test_err_context(nix: Nix):
|
||||
|
||||
@@ -8,13 +8,8 @@ from typing import Any, NamedTuple, ClassVar
|
||||
from collections.abc import Generator
|
||||
|
||||
import tomllib
|
||||
from functional2.testlib.fixtures.file_helper import (
|
||||
AssetSymlink,
|
||||
CopyFile,
|
||||
FileDeclaration,
|
||||
Fileish,
|
||||
)
|
||||
from functional2.testlib.utils import is_value_of_type, test_base_folder, get_global_asset
|
||||
from testlib.fixtures.file_helper import AssetSymlink, CopyFile, FileDeclaration, Fileish
|
||||
from testlib.utils import is_value_of_type, test_base_folder, get_global_asset
|
||||
from tomllib import TOMLDecodeError
|
||||
|
||||
LANG_TEST_ID_PATTERN = "{folder_name}:{test_name}"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
from functional2.lang.test_lang import test_eval_okay as nix_eval
|
||||
from functional2.testlib.fixtures.file_helper import AssetSymlink, CopyFile, CopyTree, with_files
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from lang.test_lang import test_eval_okay as nix_eval
|
||||
from testlib.fixtures.file_helper import AssetSymlink, CopyFile, CopyTree, with_files
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
|
||||
|
||||
@with_files(
|
||||
|
||||
@@ -7,9 +7,9 @@ import pytest
|
||||
import yaml
|
||||
from _pytest.python import Metafunc
|
||||
|
||||
from functional2.lang.lang_util import LangTest, fetch_all_lang_tests, LangTestRunner
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from lang.lang_util import LangTest, fetch_all_lang_tests, LangTestRunner
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc: Metafunc):
|
||||
|
||||
@@ -5,10 +5,10 @@ from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.command import Command
|
||||
from functional2.testlib.fixtures.file_helper import File, AssetSymlink, with_files
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from functional2.testlib.utils import get_functional2_lang_files
|
||||
from testlib.fixtures.command import Command
|
||||
from testlib.fixtures.file_helper import File, AssetSymlink, with_files
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
from testlib.utils import get_functional2_lang_files
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pytest_command", [["-k", "generic_test", "--setup-plan"]], indirect=True)
|
||||
|
||||
@@ -46,26 +46,26 @@ extend = "../../pyproject.toml"
|
||||
"os.environ".msg = """
|
||||
Environment variables are process wide and are unsafe to set as they interfere with other tests. Instead, use:
|
||||
- env= in subprocess functions
|
||||
- functional2.testlib.commands.Command.with_env for starting subprocesses
|
||||
- functional2.testlib.environ for read-only access
|
||||
- testlib.commands.Command.with_env for starting subprocesses
|
||||
- testlib.environ for read-only access
|
||||
"""
|
||||
"os.environb".msg = """
|
||||
Environment variables are process wide and are unsafe to set as they interfere with other tests. Instead, use:
|
||||
- env= in subprocess functions
|
||||
- functional2.testlib.commands.Command.with_env for starting subprocesses
|
||||
- functional2.testlib.environ for read-only access
|
||||
- testlib.commands.Command.with_env for starting subprocesses
|
||||
- testlib.environ for read-only access
|
||||
"""
|
||||
"os.putenv".msg = """
|
||||
Environment variables are process wide and are unsafe to set as they interfere with other tests. Instead, use:
|
||||
- env= in subprocess functions
|
||||
- functional2.testlib.commands.Command.with_env for starting subprocesses
|
||||
- functional2.testlib.environ for read-only access
|
||||
- testlib.commands.Command.with_env for starting subprocesses
|
||||
- testlib.environ for read-only access
|
||||
"""
|
||||
"os.unsetenv".msg = """
|
||||
Environment variables are process wide and are unsafe to set as they interfere with other tests. Instead, use:
|
||||
- env= in subprocess functions
|
||||
- functional2.testlib.commands.Command.with_env for starting subprocesses
|
||||
- functional2.testlib.environ for read-only access
|
||||
- testlib.commands.Command.with_env for starting subprocesses
|
||||
- testlib.environ for read-only access
|
||||
"""
|
||||
"os.chdir".msg = "Changing current directory is process wide and may interfere with other tests. Use cwd= while spawning a process instead."
|
||||
"os.fchdir".msg = "Changing current directory is process wide and may interfere with other tests. Use cwd= while spawning a process instead."
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset_pack
|
||||
from testlib.fixtures.file_helper import with_files
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset_pack
|
||||
|
||||
|
||||
@with_files(get_global_asset_pack("dependencies"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, File, AssetSymlink, Symlink
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.file_helper import with_files, File, AssetSymlink, Symlink
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
@with_files({"file-link": AssetSymlink("./test_add.py"), "dir-link": Symlink(".")})
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import shutil
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.utils import get_global_asset_pack
|
||||
from testlib.fixtures.file_helper import with_files
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.utils import get_global_asset_pack
|
||||
|
||||
|
||||
@with_files(get_global_asset_pack("dependencies"))
|
||||
|
||||
@@ -6,8 +6,8 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from ..testlib.fixtures.nix import Nix
|
||||
from ..testlib.nar import (
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.nar import (
|
||||
DirectoryUnordered,
|
||||
NarItem,
|
||||
NarListener,
|
||||
|
||||
@@ -4,9 +4,9 @@ import sqlite3
|
||||
import aiohttp.web as web
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import File, with_files
|
||||
from functional2.testlib.fixtures.http_server import http_server
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from testlib.fixtures.file_helper import File, with_files
|
||||
from testlib.fixtures.http_server import http_server
|
||||
from testlib.fixtures.nix import Nix
|
||||
|
||||
|
||||
class HTTPStore:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
from functional2.testlib.fixtures.file_helper import with_files, File
|
||||
from functional2.testlib.fixtures.nix import Nix
|
||||
from functional2.testlib.xattrs import verify_no_xattrs_in_tree, skip_if_xattrs_are_unsupported
|
||||
from testlib.fixtures.file_helper import with_files, File
|
||||
from testlib.fixtures.nix import Nix
|
||||
from testlib.xattrs import verify_no_xattrs_in_tree, skip_if_xattrs_are_unsupported
|
||||
|
||||
import xattr
|
||||
import json
|
||||
|
||||
@@ -9,8 +9,8 @@ from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.terminal_code_eater import eat_terminal_codes
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.terminal_code_eater import eat_terminal_codes
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import platform
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from functional2.testlib.environ import environ
|
||||
from testlib.environ import environ
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -176,7 +176,7 @@ class ManagedEnv:
|
||||
# Set to the codebase internal output if started standalone
|
||||
# This is where the current lix binaries are located.
|
||||
# local import to avoid cyclic dependencies
|
||||
from functional2.testlib.utils import lix_base_folder # noqa: PLC0415
|
||||
from testlib.utils import lix_base_folder # noqa: PLC0415
|
||||
|
||||
lix_bin = Path(environ.get("NIX_BIN_DIR", lix_base_folder / "outputs/out/bin"))
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ from collections.abc import Callable, Iterable
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.fixtures.formatter import BalancedTemplater
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.formatter import BalancedTemplater
|
||||
|
||||
|
||||
class Fileish(ABC):
|
||||
|
||||
@@ -13,9 +13,9 @@ import logging
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.command import CommandResult, Command
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.utils import is_value_of_type
|
||||
from testlib.fixtures.command import CommandResult, Command
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.utils import is_value_of_type
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
from _pytest.fixtures import FixtureRequest
|
||||
from functional2.testlib.fixtures.command import Command
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.command import Command
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
|
||||
|
||||
@pytest.fixture(name="pytest_command")
|
||||
|
||||
@@ -8,7 +8,7 @@ import pytest
|
||||
from _pytest.config import Config
|
||||
from _pytest.fixtures import FixtureRequest
|
||||
|
||||
from functional2.testlib.environ import environ
|
||||
from testlib.environ import environ
|
||||
|
||||
|
||||
def pytest_addoption(parser: pytest.Parser) -> None:
|
||||
|
||||
@@ -5,9 +5,9 @@ from subprocess import CalledProcessError
|
||||
|
||||
import pytest
|
||||
from _pytest.logging import LogCaptureFixture
|
||||
from functional2.testlib.fixtures.command import Command
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.fixtures.file_helper import File, with_files
|
||||
from testlib.fixtures.command import Command
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.file_helper import File, with_files
|
||||
|
||||
|
||||
def test_command_valid_runs(command: Callable[[list[str]], Command]):
|
||||
|
||||
@@ -6,7 +6,8 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.env import ManagedEnv, _ManagedPath
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.env import _ManagedPath
|
||||
|
||||
|
||||
def test_env_inits_defaults(tmp_path: Path):
|
||||
|
||||
@@ -2,7 +2,7 @@ from pathlib import Path
|
||||
from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
from functional2.testlib.fixtures.file_helper import (
|
||||
from testlib.fixtures.file_helper import (
|
||||
CopyFile,
|
||||
CopyTemplate,
|
||||
CopyTree,
|
||||
|
||||
@@ -3,8 +3,8 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.fixtures.nix import NixSettings
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.nix import NixSettings
|
||||
|
||||
|
||||
def test_nix_settings_serializes_xf(env: ManagedEnv):
|
||||
|
||||
@@ -5,17 +5,17 @@ from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
from _pytest.logging import LogCaptureFixture
|
||||
from functional2.testlib.fixtures.command import Command
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from functional2.testlib.fixtures.file_helper import (
|
||||
from testlib.fixtures.command import Command
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.file_helper import (
|
||||
CopyFile,
|
||||
File,
|
||||
FileDeclaration,
|
||||
merge_file_declaration,
|
||||
with_files,
|
||||
)
|
||||
from functional2.testlib.fixtures.snapshot import Snapshot
|
||||
from functional2.testlib.utils import get_functional2_files
|
||||
from testlib.fixtures.snapshot import Snapshot
|
||||
from testlib.utils import get_functional2_files
|
||||
|
||||
|
||||
def _get_f2_snapshot_files(additional_files: FileDeclaration) -> FileDeclaration:
|
||||
@@ -33,7 +33,7 @@ def _get_f2_snapshot_files(additional_files: FileDeclaration) -> FileDeclaration
|
||||
},
|
||||
},
|
||||
"conftest.py": File(
|
||||
"pytest_plugins = ('functional2.testlib.fixtures.logger', 'functional2.testlib.fixtures.snapshot')"
|
||||
"pytest_plugins = ('testlib.fixtures.logger', 'testlib.fixtures.snapshot')"
|
||||
),
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from functional2.testlib.terminal_code_eater import eat_terminal_codes
|
||||
from testlib.terminal_code_eater import eat_terminal_codes
|
||||
|
||||
|
||||
def test_eats_color():
|
||||
|
||||
@@ -2,7 +2,7 @@ from collections.abc import Callable, Generator
|
||||
from typing import Literal, Any
|
||||
|
||||
import pytest
|
||||
from functional2.testlib.utils import is_value_of_type
|
||||
from testlib.utils import is_value_of_type
|
||||
|
||||
|
||||
def test_list_type_valid():
|
||||
|
||||
@@ -6,8 +6,8 @@ from textwrap import dedent
|
||||
from types import UnionType
|
||||
from typing import Any, Literal, get_args, get_origin
|
||||
|
||||
from functional2.testlib.environ import environ
|
||||
from functional2.testlib.fixtures.file_helper import (
|
||||
from testlib.environ import environ
|
||||
from testlib.fixtures.file_helper import (
|
||||
CopyFile,
|
||||
CopyTree,
|
||||
FileDeclaration,
|
||||
@@ -53,12 +53,7 @@ def get_functional2_files(additional_files: FileDeclaration | None = None) -> Fi
|
||||
if additional_files is None:
|
||||
additional_files = {}
|
||||
return merge_file_declaration(
|
||||
{
|
||||
"functional2": {
|
||||
"__init__.py": CopyFile(functional2_base_folder / "__init__.py"),
|
||||
"pyproject.toml": CopyFile(functional2_base_folder / "pyproject.toml"),
|
||||
}
|
||||
},
|
||||
{"functional2": {"pyproject.toml": CopyFile(functional2_base_folder / "pyproject.toml")}},
|
||||
additional_files,
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import xattr
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from functional2.testlib.fixtures.env import ManagedEnv
|
||||
from testlib.fixtures.env import ManagedEnv
|
||||
|
||||
|
||||
def has_xattrs(path: Path) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user