instance_id
stringlengths 10
57
| patch
stringlengths 261
37.7k
| repo
stringlengths 7
53
| base_commit
stringlengths 40
40
| hints_text
stringclasses 301
values | test_patch
stringlengths 212
2.22M
| problem_statement
stringlengths 23
37.7k
| version
stringclasses 1
value | environment_setup_commit
stringlengths 40
40
| FAIL_TO_PASS
listlengths 1
4.94k
| PASS_TO_PASS
listlengths 0
7.82k
| meta
dict | created_at
stringlengths 25
25
| license
stringclasses 8
values | __index_level_0__
int64 0
6.41k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
twosixlabs__armory-277 | diff --git a/armory/data/README.md b/armory/data/README.md
index 26bb48eb..870ca113 100644
--- a/armory/data/README.md
+++ b/armory/data/README.md
@@ -1,20 +1,37 @@
# Datasets
-The data module implements functionality to download external and internal datasets to
-the armory repository and standardizes them across all evaluations.
+The datasets module implements functionality to download external and internal
+datasets to the armory repository and standardizes them across all evaluations.
+
+### Image Datasets
+
+| Dataset | Description | x_shape | x_dtype | y_shape | y_dtype |
+|:---------- |:----------- |:------- |:-------- |:-------- |:------- |
+| `cifar10` | CIFAR 10 classes image dataset | (N, 32, 32, 3) | uint8 | (N,) | int64 |
+| `german_traffic_sign` | German traffic sign dataset | (N, variable_height, variable_width, 3) | uint8 | (N,) | int64 |
+| `imagenet_adversarial` | ILSVRC12 adversarial image dataset from ResNet50 | (N, 224, 224, 3) | float32 | (N,) | int32 |
+| `imagenette` | Smaller subset of 10 classes from Imagenet | (N, variable_height, variable_width, 3) | uint8 | (N,) | int64 |
+| `mnist` | MNIST hand written digit image dataset | (N, 28, 28, 1) | uint8 | (N,) | int64 |
+| `resisc45` | REmote Sensing Image Scene Classification | (N, 256, 256, 3) | uint8 | (N,) | int64 |
+
+### Audio Datasets
+| Dataset | Description | x_shape | x_dtype | y_shape | y_dtype |
+|:---------- |:----------- |:------- |:-------- |:-------- |:------- |
+| `digit` | Audio dataset of spoken digits | (N, variable_length) | int16 | (N,) | int64 |
+| `librispeech_dev_clean` | Librispeech dev dataset for speaker identification | (N, variable_length) | int64 | (N,) | int64 |
+
+### Video Datasets
+| Dataset | Description | x_shape | x_dtype | y_shape | y_dtype |
+|:---------- |:----------- |:------- |:-------- |:-------- |:------- |
+| `ucf101` | UCF 101 Action Recognition | (N, variable_frames, 240, 320, 3) | uint8 | (N,) | int64 |
-### Available Datasets
-* `mnist` : MNIST hand written digit image dataset
-* `cifar10`: CIFAR 10 classes image dataset
-* `digit`: Audio dataset of spoken digits
-* `imagenet_adversarial`: ILSVRC12 adversarial image dataset for ResNet50
### TF Data Loading
We load datasets using `tf.data` and convert the data to numpy arrays for ingestion in
any framework. While not the most efficient strategy, this current implementation
helps us standardize evaluations across all frameworks.
-### In-Memory or Generator
-At the moment we have all datasets return as in memory NumPy arrays. This was done for
-the initial release so all examples align with their ART counterparts. Going forward
-we plan to generators so that larger datasets can be processed.
\ No newline at end of file
+### ArmoryDataSet Generator
+* All DataSets return an `ArmoryDataGenerator` which implements the methods needed
+by the ART framework. Specifically `get_batch` will return a tuple of `(data, labels)`
+for a specficied batch size.
diff --git a/armory/docker/management.py b/armory/docker/management.py
index 013341fa..8e665e40 100644
--- a/armory/docker/management.py
+++ b/armory/docker/management.py
@@ -19,11 +19,22 @@ class ArmoryInstance(object):
"""
def __init__(
- self, image_name, runtime: str = "runc", envs: dict = None, ports: dict = None
+ self,
+ image_name,
+ runtime: str = "runc",
+ envs: dict = None,
+ ports: dict = None,
+ container_subdir: str = None,
):
+ self.docker_client = docker.from_env(version="auto")
+
host_paths = paths.host()
docker_paths = paths.docker()
- self.docker_client = docker.from_env(version="auto")
+ host_tmp_dir = host_paths.tmp_dir
+ host_output_dir = host_paths.output_dir
+ if container_subdir:
+ host_tmp_dir = os.path.join(host_tmp_dir, container_subdir)
+ host_output_dir = os.path.join(host_output_dir, container_subdir)
container_args = {
"runtime": runtime,
@@ -39,8 +50,8 @@ def __init__(
"bind": docker_paths.saved_model_dir,
"mode": "rw",
},
- host_paths.output_dir: {"bind": docker_paths.output_dir, "mode": "rw"},
- host_paths.tmp_dir: {"bind": docker_paths.tmp_dir, "mode": "rw"},
+ host_output_dir: {"bind": docker_paths.output_dir, "mode": "rw"},
+ host_tmp_dir: {"bind": docker_paths.tmp_dir, "mode": "rw"},
},
}
if ports is not None:
@@ -87,10 +98,14 @@ def __init__(self, image_name: str, runtime="runc"):
self.name = image_name
def start_armory_instance(
- self, envs: dict = None, ports: dict = None
+ self, envs: dict = None, ports: dict = None, container_subdir: str = None,
) -> ArmoryInstance:
temp_inst = ArmoryInstance(
- self.name, runtime=self.runtime, envs=envs, ports=ports
+ self.name,
+ runtime=self.runtime,
+ envs=envs,
+ ports=ports,
+ container_subdir=container_subdir,
)
self.instances[temp_inst.docker_container.short_id] = temp_inst
return temp_inst
diff --git a/armory/docker/volumes_util.py b/armory/docker/volumes_util.py
new file mode 100644
index 00000000..ced52680
--- /dev/null
+++ b/armory/docker/volumes_util.py
@@ -0,0 +1,42 @@
+"""
+Utility functions for dealing with docker directories and mounted volumes
+"""
+
+import datetime
+import logging
+import os
+
+from armory import paths
+
+logger = logging.getLogger(__name__)
+
+
+def tmp_output_subdir(retries=10):
+ """
+ Return (<subdir name>, <tmp subdir path>, <output subdir path>)
+
+ retries - number of times to retry folder creation before returning an error
+ if retries < 0, it will retry indefinitely.
+ retries are necessary to prevent timestamp collisions.
+ """
+ tries = int(retries) + 1
+ host_paths = paths.host()
+ while tries:
+ subdir = datetime.datetime.utcnow().isoformat()
+ # ":" characters violate docker-py volume specifications
+ subdir = subdir.replace(":", "-")
+ # Use tmp_subdir for locking
+ try:
+ tmp_subdir = os.path.join(host_paths.tmp_dir, subdir)
+ os.mkdir(tmp_subdir)
+ except FileExistsError:
+ tries -= 1
+ if tries:
+ logger.warning(f"Failed to create {tmp_subdir}. Retrying...")
+ continue
+
+ output_subdir = os.path.join(host_paths.output_dir, subdir)
+ os.mkdir(output_subdir)
+ return subdir, tmp_subdir, output_subdir
+
+ raise ValueError("Failed to create tmp and output subdirectories")
diff --git a/armory/eval/evaluator.py b/armory/eval/evaluator.py
index 0f33fd6c..50e939a3 100644
--- a/armory/eval/evaluator.py
+++ b/armory/eval/evaluator.py
@@ -15,6 +15,7 @@
from docker.errors import ImageNotFound
from armory.docker.management import ManagementInstance
+from armory.docker import volumes_util
from armory.utils.configuration import load_config
from armory.utils import external_repo
from armory.utils.printing import bold, red
@@ -43,9 +44,17 @@ def __init__(
self.config = config_path
else:
raise ValueError(f"config_path {config_path} must be a str or dict")
- self.tmp_config = os.path.join(self.host_paths.tmp_dir, container_config_name)
+ (
+ self.container_subdir,
+ self.tmp_dir,
+ self.output_dir,
+ ) = volumes_util.tmp_output_subdir()
+ self.tmp_config = os.path.join(self.tmp_dir, container_config_name)
+ self.external_repo_dir = paths.get_external(self.tmp_dir)
self.docker_config_path = Path(
- os.path.join(self.docker_paths.tmp_dir, container_config_name)
+ os.path.join(
+ self.docker_paths.tmp_dir, self.container_subdir, container_config_name
+ )
).as_posix()
kwargs = dict(runtime="runc")
@@ -71,16 +80,22 @@ def __init__(
except ImageNotFound:
logger.info(f"Image {image_name} was not found. Downloading...")
docker_api.pull_verbose(docker_client, image_name)
+ except requests.exceptions.ConnectionError:
+ logger.error(f"Docker connection refused. Is Docker Daemon running?")
+ raise
self.manager = ManagementInstance(**kwargs)
def _download_external(self):
external_repo.download_and_extract_repo(
- self.config["sysconfig"]["external_github_repo"]
+ self.config["sysconfig"]["external_github_repo"],
+ external_repo_dir=self.external_repo_dir,
)
def _download_private(self):
- external_repo.download_and_extract_repo("twosixlabs/armory-private")
+ external_repo.download_and_extract_repo(
+ "twosixlabs/armory-private", external_repo_dir=self.external_repo_dir
+ )
self.extra_env_vars.update(
{
"ARMORY_PRIVATE_S3_ID": os.getenv("ARMORY_PRIVATE_S3_ID"),
@@ -89,26 +104,34 @@ def _download_private(self):
)
def _write_tmp(self):
- os.makedirs(self.host_paths.tmp_dir, exist_ok=True)
+ os.makedirs(self.tmp_dir, exist_ok=True)
if os.path.exists(self.tmp_config):
logger.warning(f"Overwriting previous temp config: {self.tmp_config}...")
with open(self.tmp_config, "w") as f:
json.dump(self.config, f)
def _delete_tmp(self):
- if os.path.exists(self.host_paths.external_repo_dir):
+ if os.path.exists(self.external_repo_dir):
try:
- shutil.rmtree(self.host_paths.external_repo_dir)
+ shutil.rmtree(self.external_repo_dir)
except OSError as e:
if not isinstance(e, FileNotFoundError):
logger.exception(
- f"Error removing external repo {self.host_paths.external_repo_dir}"
+ f"Error removing external repo {self.external_repo_dir}"
)
+
+ logger.info(f"Deleting tmp_dir {self.tmp_dir}")
try:
- os.remove(self.tmp_config)
+ shutil.rmtree(self.tmp_dir)
except OSError as e:
if not isinstance(e, FileNotFoundError):
- logger.exception(f"Error removing tmp config {self.tmp_config}")
+ logger.exception(f"Error removing tmp_dir {self.tmp_dir}")
+
+ logger.info(f"Removing output_dir {self.output_dir} if empty")
+ try:
+ os.rmdir(self.output_dir)
+ except OSError:
+ pass
def run(
self, interactive=False, jupyter=False, host_port=8888, command=None
@@ -118,8 +141,11 @@ def run(
ports = {container_port: host_port} if jupyter else None
try:
runner = self.manager.start_armory_instance(
- envs=self.extra_env_vars, ports=ports
+ envs=self.extra_env_vars,
+ ports=ports,
+ container_subdir=self.container_subdir,
)
+ logger.warning(f"Outputs will be written to {self.output_dir}")
try:
if jupyter:
self._run_jupyter(runner, host_port=host_port)
diff --git a/armory/paths.py b/armory/paths.py
index 710bd802..930e4948 100644
--- a/armory/paths.py
+++ b/armory/paths.py
@@ -105,6 +105,10 @@ def __init__(self):
os.makedirs(self.output_dir, exist_ok=True)
+def get_external(tmp_dir):
+ return os.path.join(tmp_dir, "external")
+
+
class HostDefault:
def __init__(self):
self.cwd = os.getcwd()
@@ -116,7 +120,7 @@ def __init__(self):
self.saved_model_dir = os.path.join(self.armory_dir, "saved_models")
self.tmp_dir = os.path.join(self.armory_dir, "tmp")
self.output_dir = os.path.join(self.armory_dir, "outputs")
- self.external_repo_dir = os.path.join(self.tmp_dir, "external")
+ self.external_repo_dir = get_external(self.tmp_dir)
class DockerPaths:
diff --git a/armory/utils/external_repo.py b/armory/utils/external_repo.py
index c0a49ff8..9e28570f 100644
--- a/armory/utils/external_repo.py
+++ b/armory/utils/external_repo.py
@@ -14,16 +14,19 @@
logger = logging.getLogger(__name__)
-def download_and_extract_repo(external_repo_name: str) -> None:
+def download_and_extract_repo(
+ external_repo_name: str, external_repo_dir: str = None
+) -> None:
"""
Downloads and extracts an external repository for use within ARMORY.
Private repositories require a `GITHUB_TOKEN` environment variable.
:param external_repo_name: String name of "organization/repo-name"
"""
- host_paths = paths.host()
+ if external_repo_dir is None:
+ external_repo_dir = paths.host().external_repo_dir
- os.makedirs(host_paths.external_repo_dir, exist_ok=True)
+ os.makedirs(external_repo_dir, exist_ok=True)
headers = {}
repo_name = external_repo_name.split("/")[-1]
@@ -39,20 +42,19 @@ def download_and_extract_repo(external_repo_name: str) -> None:
if response.status_code == 200:
logging.info(f"Downloading external repo: {external_repo_name}")
- tar_filename = os.path.join(host_paths.external_repo_dir, repo_name + ".tar.gz")
+ tar_filename = os.path.join(external_repo_dir, repo_name + ".tar.gz")
with open(tar_filename, "wb") as f:
f.write(response.raw.read())
tar = tarfile.open(tar_filename, "r:gz")
dl_directory_name = tar.getnames()[0]
- tar.extractall(path=host_paths.external_repo_dir)
+ tar.extractall(path=external_repo_dir)
# Always overwrite existing repositories to keep them at HEAD
- final_dir_name = os.path.join(host_paths.external_repo_dir, repo_name)
+ final_dir_name = os.path.join(external_repo_dir, repo_name)
if os.path.isdir(final_dir_name):
shutil.rmtree(final_dir_name)
os.rename(
- os.path.join(host_paths.external_repo_dir, dl_directory_name),
- final_dir_name,
+ os.path.join(external_repo_dir, dl_directory_name), final_dir_name,
)
# os.remove(tar_filename)
| twosixlabs/armory | 00068e44a1a43e9a119f93438b934c4633eb68fd | diff --git a/tests/test_host/test_external_repo.py b/tests/test_host/test_external_repo.py
index 726d4f34..6b6cdb71 100644
--- a/tests/test_host/test_external_repo.py
+++ b/tests/test_host/test_external_repo.py
@@ -9,20 +9,17 @@
class ExternalRepoTest(unittest.TestCase):
def test_download(self):
- host_paths = paths.host()
+ tmp_subdir = pathlib.Path(paths.host().tmp_dir, "test-external-repo-subdir")
+ external_repo_dir = pathlib.Path(paths.get_external(tmp_subdir))
repo = "twosixlabs/armory-example"
repo_name = repo.split("/")[-1]
- download_and_extract_repo(repo)
- self.assertTrue(os.path.exists(f"{host_paths.external_repo_dir}/{repo_name}"))
- self.assertTrue(
- os.path.isfile(
- str(
- pathlib.Path(
- f"{host_paths.external_repo_dir}/{repo_name}/README.md"
- )
- )
- )
- )
+ download_and_extract_repo(repo, external_repo_dir=external_repo_dir)
+ basedir = external_repo_dir / repo_name
- shutil.rmtree(str(pathlib.Path(f"{host_paths.external_repo_dir}/{repo_name}")))
+ self.assertTrue(os.path.exists(basedir))
+ self.assertTrue(os.path.isfile(basedir / "README.md"))
+ shutil.rmtree(basedir)
+ os.remove(external_repo_dir / (repo_name + ".tar.gz"))
+ os.rmdir(external_repo_dir)
+ os.rmdir(tmp_subdir)
| Multiple Docker container write/delete collisions
Currently, the `tmp` directory (including the evaluation file) is created and deleted by each docker container. The evaluation file may also be overwritten by a second docker container running concurrently. Similar issues may exist with the output directory and the data directory (I am unsure what would happen if two docker containers attempted to download the same model or dataset simultaneously).
For multiuser systems and evaluations with multiple containers, this behavior will need to be modified. | 0.0 | 00068e44a1a43e9a119f93438b934c4633eb68fd | [
"tests/test_host/test_external_repo.py::ExternalRepoTest::test_download"
]
| []
| {
"failed_lite_validators": [
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2020-03-18 00:46:18+00:00 | mit | 6,135 |
|
twu__skjold-140 | diff --git a/src/skjold/sources/pyup.py b/src/skjold/sources/pyup.py
index 5df83b3..d41755c 100644
--- a/src/skjold/sources/pyup.py
+++ b/src/skjold/sources/pyup.py
@@ -36,7 +36,10 @@ class PyUpSecurityAdvisory(SecurityAdvisory):
@property
def url(self) -> str:
- return f"https://pyup.io/{self.identifier}"
+ path = self._json.get("more_info_path")
+ if not path:
+ return ""
+ return f"https://pyup.io{path}"
@property
def references(self) -> List[str]:
| twu/skjold | d749b200476bbdcd20ae7bfe4869619534176f3c | diff --git a/tests/test_pyup.py b/tests/test_pyup.py
index 8508def..828c019 100644
--- a/tests/test_pyup.py
+++ b/tests/test_pyup.py
@@ -10,7 +10,7 @@ from skjold.sources.pyup import PyUp, PyUpSecurityAdvisory
@pytest.mark.parametrize(
- "name, raw",
+ "name, raw, expected_url",
[
(
"package_name",
@@ -21,10 +21,25 @@ from skjold.sources.pyup import PyUp, PyUpSecurityAdvisory
"specs": ["<1.0.0", ">=1.1,<1.1.1"],
"v": "<1.0.4,>=1.1,<1.1.1",
},
- )
+ "",
+ ),
+ (
+ "package_name",
+ {
+ "advisory": "Advisory summary.",
+ "cve": "CVE-200X-XXXX",
+ "id": "pyup.io-XXXXXX",
+ "specs": ["<1.0.0", ">=1.1,<1.1.1"],
+ "v": "<1.0.4,>=1.1,<1.1.1",
+ "more_info_path": "/vulnerabilities/CVE-1970-0001/12345/",
+ },
+ "https://pyup.io/vulnerabilities/CVE-1970-0001/12345/",
+ ),
],
)
-def test_ensure_using_build_obj(name: str, raw: Dict[Any, Any]) -> None:
+def test_ensure_using_build_obj(
+ name: str, raw: Dict[Any, Any], expected_url: str
+) -> None:
obj = PyUpSecurityAdvisory.using(name, raw)
assert obj.package_name == "package_name"
assert obj.canonical_name == "package-name"
@@ -32,7 +47,7 @@ def test_ensure_using_build_obj(name: str, raw: Dict[Any, Any]) -> None:
assert obj.source == "pyup"
assert obj.summary == "Advisory summary."
assert obj.severity == "UNKNOWN"
- assert obj.url == "https://pyup.io/pyup.io-XXXXXX"
+ assert obj.url == expected_url
assert obj.references == []
assert obj.vulnerable_versions == "<1.0.0,<1.1.1,>=1.1"
| Links to pyup.io point to 404 page
Here's an example of an issue reported by skjold:
```
cryptography==38.0.1 (<39.0.0) via pyup as pyup.io-51159 found in poetry.lock
Cryptography 39.0.0 drops support for C library "LibreSSL" < 3.4, as these
versions are not receiving security support anymore.
https://pyup.io/pyup.io-51159
```
The link at the last line points to https://pyup.io/pyup.io-51159, however it should point to https://pyup.io/vulnerabilities/CVE-2021-41581/51159/
It's likely appending the `id` instead of the `more_info_path` to the domain when constructing the link. | 0.0 | d749b200476bbdcd20ae7bfe4869619534176f3c | [
"tests/test_pyup.py::test_ensure_using_build_obj[package_name-raw0-]",
"tests/test_pyup.py::test_ensure_using_build_obj[package_name-raw1-https://pyup.io/vulnerabilities/CVE-1970-0001/12345/]"
]
| [
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-0.9.1-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-0.9.9-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-1.1.0-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-1.1.1-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-1.1.2-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-2.0.0-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-2.2.0-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-0.9.1-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-0.9.9-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-1.1.0-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-1.1.1-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-1.1.2-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-2.0.0-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-2.2.0-False]",
"tests/test_pyup.py::test_ensure_is_affected_single[package-0.9.4-False]",
"tests/test_pyup.py::test_ensure_is_affected_single[package-1.0.0-True]",
"tests/test_pyup.py::test_ensure_is_affected_single[package-2.0.0-False]",
"tests/test_pyup.py::test_ensure_source_is_affected_single[pyup-dependency0-True]",
"tests/test_pyup.py::test_ensure_source_is_affected_single[pyup-dependency1-True]",
"tests/test_pyup.py::test_ensure_source_is_affected_single[pyup-dependency2-True]",
"tests/test_pyup.py::test_ensure_source_is_affected_single[pyup-dependency3-True]",
"tests/test_pyup.py::test_ensure_source_is_affected_single[pyup-dependency4-True]",
"tests/test_pyup.py::test_ensure_source_is_affected_single[pyup-dependency7-False]",
"tests/test_pyup.py::test_pyup_handle_metadata",
"tests/test_pyup.py::test_ensure_accessing_advisories_triggers_update"
]
| {
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-10-03 17:41:12+00:00 | mit | 6,136 |
|
twu__skjold-149 | diff --git a/src/skjold/sources/pyup.py b/src/skjold/sources/pyup.py
index d41755c..65f963a 100644
--- a/src/skjold/sources/pyup.py
+++ b/src/skjold/sources/pyup.py
@@ -24,7 +24,7 @@ class PyUpSecurityAdvisory(SecurityAdvisory):
@property
def identifier(self) -> str:
- return self._json["id"]
+ return self._json["cve"]
@property
def source(self) -> str:
| twu/skjold | e02f9d40e872ec6ac86a877f4e443970e1d0134b | diff --git a/tests/test_pyup.py b/tests/test_pyup.py
index 828c019..eaa7830 100644
--- a/tests/test_pyup.py
+++ b/tests/test_pyup.py
@@ -43,7 +43,7 @@ def test_ensure_using_build_obj(
obj = PyUpSecurityAdvisory.using(name, raw)
assert obj.package_name == "package_name"
assert obj.canonical_name == "package-name"
- assert obj.identifier == "pyup.io-XXXXXX"
+ assert obj.identifier == "CVE-200X-XXXX"
assert obj.source == "pyup"
assert obj.summary == "Advisory summary."
assert obj.severity == "UNKNOWN"
@@ -144,7 +144,7 @@ def pyup_advisories_with_metadata() -> Any:
},
"package": [{
"advisory": "...",
- "cve": null,
+ "cve": "CVE-200X-XXXX",
"id": "pyup.io-XXXXX",
"specs": [">0", "<0"],
"v": ">0,<0"
| Inconsequent ignoring
Let's take a look at this example:
```
% echo "py==1.11.0" | skjold audit -s pyup -s gemnasium -
Warning: No advisory sources configured!
py==1.11.0 (<=1.11.0) via gemnasium as CVE-2022-42969 found in <stdin>
Regular expression Denial of Service. The py library through 1.11.0 for Python
allows remote attackers to conduct a ReDoS (Regular expression Denial of
Service) attack via a Subversion repository with crafted info data, because the
InfoSvnCommand argument is mishandled.
https://nvd.nist.gov/vuln/detail/CVE-2022-42969
https://nvd.nist.gov/vuln/detail/CVE-2022-42969
https://pypi.org/project/py
https://github.com/pytest-dev/py/blob/cb87a83960523a2367d0f19226a73aed4ce4291d/py/_path/svnurl.py#L316
https://github.com/pytest-dev/py/issues/287
--
py==1.11.0 (<=1.11.0) via pyup as pyup.io-51457 found in <stdin>
Py throughout 1.11.0 allows remote attackers to conduct a ReDoS (Regular
expression Denial of Service) attack via a Subversion repository with crafted
info data, because the InfoSvnCommand argument is mishandled.
https://github.com/pytest-dev/py/issues/287
https://pyup.io/vulnerabilities/CVE-2022-42969/51457/
--
Found 1 vulnerable package(s)!
```
Both `pyup` and `gemnasium` finds this package as a vulnerability. However when using `pyup` as a source, it's identified as `pyup.io-51457`, not as `CVE-2022-42969`, like it is when using `gemnasium`. Thus, if you want to ignore this finding, you will have to run `skjold ignore py CVE-2022-42969` and `skjold ignore py pyup.io-51457` to ignore both of these.
I'm guessing there's just some error (or inconsistency) in how the data from `pyup` is parsed, as the raw data contains the CVE.
Changing this behaviour can of course break some existing ignore files, but would still be nice if it would work intuitively and following the examples on how to ignore the finding. | 0.0 | e02f9d40e872ec6ac86a877f4e443970e1d0134b | [
"tests/test_pyup.py::test_ensure_using_build_obj[package_name-raw0-]",
"tests/test_pyup.py::test_ensure_using_build_obj[package_name-raw1-https://pyup.io/vulnerabilities/CVE-1970-0001/12345/]"
]
| [
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-0.9.1-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-0.9.9-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-1.1.0-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-1.1.1-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-1.1.2-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-2.0.0-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs0-package-2.2.0-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-0.9.1-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-0.9.9-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-1.1.0-True]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-1.1.1-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-1.1.2-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-2.0.0-False]",
"tests/test_pyup.py::test_ensure_is_affected[specs1-package-2.2.0-False]",
"tests/test_pyup.py::test_ensure_is_affected_single[package-0.9.4-False]",
"tests/test_pyup.py::test_ensure_is_affected_single[package-1.0.0-True]",
"tests/test_pyup.py::test_ensure_is_affected_single[package-2.0.0-False]",
"tests/test_pyup.py::test_pyup_handle_metadata"
]
| {
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-11-05 15:51:29+00:00 | mit | 6,137 |
|
tylerwince__pydbg-4 | diff --git a/.travis.yml b/.travis.yml
index e1b9f62..0b6f2c8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,7 +10,7 @@ python:
- "nightly"
# command to install dependencies
install:
- - pip install pydbg
+ - pip install -e .
# command to run tests
script:
- pytest -vv
diff --git a/pydbg.py b/pydbg.py
index 3695ef8..a5b06df 100644
--- a/pydbg.py
+++ b/pydbg.py
@@ -27,7 +27,10 @@ def dbg(exp):
for i in reversed(inspect.stack()):
if "dbg" in i.code_context[0]:
var_name = i.code_context[0][
- i.code_context[0].find("(") + 1 : i.code_context[0].find(")")
+ i.code_context[0].find("(")
+ + 1 : len(i.code_context[0])
+ - 1
+ - i.code_context[0][::-1].find(")")
]
print(f"[{i.filename}:{i.lineno}] {var_name} = {exp}")
break
| tylerwince/pydbg | e29ce20677f434dcf302c2c6f7bd872d26d4f13b | diff --git a/tests/test_pydbg.py b/tests/test_pydbg.py
index 5b12508..bf91ea4 100644
--- a/tests/test_pydbg.py
+++ b/tests/test_pydbg.py
@@ -4,9 +4,6 @@ from pydbg import dbg
from contextlib import redirect_stdout
-def something():
- pass
-
cwd = os.getcwd()
def test_variables():
@@ -23,12 +20,19 @@ def test_variables():
dbg(strType)
dbg(boolType)
dbg(NoneType)
+ dbg(add(1, 2))
- want = f"""[{cwd}/tests/test_pydbg.py:21] intType = 2
-[{cwd}/tests/test_pydbg.py:22] floatType = 2.1
-[{cwd}/tests/test_pydbg.py:23] strType = mystring
-[{cwd}/tests/test_pydbg.py:24] boolType = True
-[{cwd}/tests/test_pydbg.py:25] NoneType = None
+ want = f"""[{cwd}/tests/test_pydbg.py:18] intType = 2
+[{cwd}/tests/test_pydbg.py:19] floatType = 2.1
+[{cwd}/tests/test_pydbg.py:20] strType = mystring
+[{cwd}/tests/test_pydbg.py:21] boolType = True
+[{cwd}/tests/test_pydbg.py:22] NoneType = None
+[{cwd}/tests/test_pydbg.py:23] add(1, 2) = 3
"""
- assert out.getvalue() == want
+ assert out.getvalue() == want
+
+
+def add(x, y):
+ return x + y
+
| Parentheses aren't displayed correctly for functions
The closing parentheses around the function call is missing.
```
In [19]: def add(x, y):
...: z = x + y
...: return z
...:
In [20]: dbg(add(1, 2))
[<ipython-input-20-ac7b28727082>:1] add(1, 2 = 3
``` | 0.0 | e29ce20677f434dcf302c2c6f7bd872d26d4f13b | [
"tests/test_pydbg.py::test_variables"
]
| []
| {
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2019-01-21 17:37:47+00:00 | mit | 6,138 |
|
typesafehub__conductr-cli-339 | diff --git a/conductr_cli/sandbox_main.py b/conductr_cli/sandbox_main.py
index 657dd85..d07aba2 100644
--- a/conductr_cli/sandbox_main.py
+++ b/conductr_cli/sandbox_main.py
@@ -33,6 +33,7 @@ def build_parser():
add_image_dir(run_parser)
run_parser.add_argument('image_version',
nargs='?',
+ type=validation.argparse_version,
help='Version of the ConductR docker image to use\n'
'To obtain the current version and additional information, please visit\n'
'http://lightbend.com/product/conductr/developer')
diff --git a/conductr_cli/validation.py b/conductr_cli/validation.py
index 201c7c3..88143b2 100644
--- a/conductr_cli/validation.py
+++ b/conductr_cli/validation.py
@@ -464,3 +464,13 @@ def format_timestamp(timestamp, args):
def get_logger_for_func(func):
return logging.getLogger('conductr_cli.{}'.format(func.__name__))
+
+
+def argparse_version(value):
+ import argparse
+ import re
+
+ if re.match("^[0-9]+([.][0-9]+)*$", value):
+ return value
+
+ raise argparse.ArgumentTypeError("'%s' is not a valid version number" % value)
| typesafehub/conductr-cli | 35f1373ade96070d41f733981acf9f4d9e418012 | diff --git a/conductr_cli/test/test_validation.py b/conductr_cli/test/test_validation.py
new file mode 100644
index 0000000..049ebd2
--- /dev/null
+++ b/conductr_cli/test/test_validation.py
@@ -0,0 +1,30 @@
+from argparse import ArgumentTypeError
+from conductr_cli.validation import argparse_version
+from conductr_cli.test.cli_test_case import CliTestCase
+
+
+class TestTerminal(CliTestCase):
+ def test_argparse_version_number(self):
+ def expect_fail(value):
+ passed = False
+
+ try:
+ argparse_version(value)
+ except ArgumentTypeError:
+ passed = True
+
+ self.assertTrue(passed)
+
+ def expect_pass(value):
+ self.assertEqual(argparse_version(value), value)
+
+ expect_pass('1')
+ expect_pass('1.1')
+ expect_pass('1.1.0')
+ expect_pass('1.2.3.4.5')
+ expect_pass('2')
+ expect_pass('2.0.0')
+
+ expect_fail('potato')
+ expect_fail('1.')
+ expect_fail(' asdf 1 hello')
| Running sandbox with unparseable version should give nicer error
When I run `sandbox run abc`, I expect the program will give me an error that is understandable.
Instead, I get this:
```
~/work/conductr-crash/target/bundle $ sandbox run abc
Error: Encountered unexpected error.
Error: Reason: ValueError invalid literal for int() with base 10: 'a'
Error: Further information of the error can be found in the error log file: /home/longshorej/.conductr/errors.log
-> 1
``` | 0.0 | 35f1373ade96070d41f733981acf9f4d9e418012 | [
"conductr_cli/test/test_validation.py::TestTerminal::test_argparse_version_number"
]
| []
| {
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2017-03-08 21:06:27+00:00 | apache-2.0 | 6,139 |
|
typesafehub__conductr-cli-433 | diff --git a/conductr_cli/resolvers/bintray_resolver.py b/conductr_cli/resolvers/bintray_resolver.py
index 6418e4a..b6fc839 100644
--- a/conductr_cli/resolvers/bintray_resolver.py
+++ b/conductr_cli/resolvers/bintray_resolver.py
@@ -1,9 +1,9 @@
from conductr_cli.exceptions import MalformedBundleUriError, BintrayResolutionError, \
BintrayCredentialsNotFoundError, MalformedBintrayCredentialsError
from conductr_cli.resolvers import uri_resolver
+from conductr_cli.resolvers.resolvers_util import is_local_file
from conductr_cli import bundle_shorthand
from requests.exceptions import HTTPError, ConnectionError
-from urllib.parse import urlparse
import json
import logging
import os
@@ -142,24 +142,6 @@ def continuous_delivery_uri(resolved_version):
return None
-def any_subdir_contains(dir, name):
- for dir, sub_dirs, files in os.walk(dir):
- if name in files:
- return True
-
- return False
-
-
-def is_local_file(uri, require_bundle_conf):
- parsed = urlparse(uri, scheme='file')
-
- return parsed.scheme == 'file' and os.path.exists(parsed.path) and (
- not require_bundle_conf or os.path.isfile(parsed.path) or (
- os.path.isdir(parsed.path) and any_subdir_contains(parsed.path, 'bundle.conf')
- )
- )
-
-
def bintray_download_artefact(cache_dir, artefact, auth):
if artefact:
return uri_resolver.resolve_file(cache_dir, artefact['download_url'], auth)
diff --git a/conductr_cli/resolvers/docker_resolver.py b/conductr_cli/resolvers/docker_resolver.py
index b8e4308..688c6ff 100644
--- a/conductr_cli/resolvers/docker_resolver.py
+++ b/conductr_cli/resolvers/docker_resolver.py
@@ -1,9 +1,10 @@
from collections import OrderedDict
from conductr_cli import screen_utils
from conductr_cli.constants import IO_CHUNK_SIZE
+from conductr_cli.resolvers.resolvers_util import is_local_file
from functools import partial
from requests.auth import HTTPBasicAuth
-from urllib.parse import urlencode, urlparse
+from urllib.parse import urlencode
import gzip
import hashlib
import logging
@@ -169,7 +170,7 @@ def resolve_bundle(cache_dir, uri, auth=None):
def do_resolve_bundle(cache_dir, uri, auth, offline_mode):
log = logging.getLogger(__name__)
- if is_local_file(uri):
+ if is_local_file(uri, require_bundle_conf=True):
return False, None, None
(provided_url, url), (provided_ns, ns), (provided_image, image), (provided_tag, tag) = parse_uri(uri)
@@ -278,11 +279,6 @@ def is_bundle_name(uri):
return uri.count('/') == 0 and uri.count('.') == 0
-def is_local_file(uri):
- parsed = urlparse(uri, scheme='file')
- return parsed.scheme == 'file' and os.path.exists(parsed.path)
-
-
def load_docker_credentials(server):
log = logging.getLogger(__name__)
diff --git a/conductr_cli/resolvers/resolvers_util.py b/conductr_cli/resolvers/resolvers_util.py
new file mode 100644
index 0000000..21aed5e
--- /dev/null
+++ b/conductr_cli/resolvers/resolvers_util.py
@@ -0,0 +1,15 @@
+from conductr_cli.bndl_utils import detect_format_dir
+from urllib.parse import urlparse
+import os
+
+
+def is_local_file(uri, require_bundle_conf):
+ parsed = urlparse(uri, scheme='file')
+
+ return parsed.scheme == 'file' and os.path.exists(parsed.path) and (
+ os.path.isfile(parsed.path) or (
+ os.path.isdir(parsed.path) and
+ detect_format_dir(parsed.path) is not None and
+ (not require_bundle_conf or os.path.exists(os.path.join(parsed.path, 'bundle.conf')))
+ )
+ )
| typesafehub/conductr-cli | c8a3c9f17c49c889fcfc09da933c3a3e89b3d96c | diff --git a/conductr_cli/resolvers/test/test_resolvers_util.py b/conductr_cli/resolvers/test/test_resolvers_util.py
new file mode 100644
index 0000000..b72c0a1
--- /dev/null
+++ b/conductr_cli/resolvers/test/test_resolvers_util.py
@@ -0,0 +1,41 @@
+from unittest import TestCase
+from conductr_cli.resolvers import resolvers_util
+import os
+import shutil
+import tempfile
+
+
+class TestResolveBundle(TestCase):
+ def test_is_local_file_with_file(self):
+ with tempfile.NamedTemporaryFile() as temp:
+ self.assertTrue(resolvers_util.is_local_file(temp.name, require_bundle_conf=True))
+ self.assertTrue(resolvers_util.is_local_file(temp.name, require_bundle_conf=False))
+
+ def test_is_local_file_with_empty_dir(self):
+ temp = tempfile.mkdtemp()
+
+ try:
+ self.assertFalse(resolvers_util.is_local_file(temp, require_bundle_conf=True))
+ self.assertFalse(resolvers_util.is_local_file(temp, require_bundle_conf=False))
+ finally:
+ shutil.rmtree(temp)
+
+ def test_is_local_file_with_bundle_dir(self):
+ temp = tempfile.mkdtemp()
+ open(os.path.join(temp, 'bundle.conf'), 'w').close()
+
+ try:
+ self.assertTrue(resolvers_util.is_local_file(temp, require_bundle_conf=True))
+ self.assertTrue(resolvers_util.is_local_file(temp, require_bundle_conf=False))
+ finally:
+ shutil.rmtree(temp)
+
+ def test_is_local_file_with_bundle_conf_dir(self):
+ temp = tempfile.mkdtemp()
+ open(os.path.join(temp, 'runtime-config.sh'), 'w').close()
+
+ try:
+ self.assertFalse(resolvers_util.is_local_file(temp, require_bundle_conf=True))
+ self.assertTrue(resolvers_util.is_local_file(temp, require_bundle_conf=False))
+ finally:
+ shutil.rmtree(temp)
| Conduct load command may resolve directory incorrectly
Conduct load command may fail unexpectedly with the following message:
```
Felixs-MBP-2:conductr felixsatyaputra$ sandbox run 0.1.0 -n 3:3
|------------------------------------------------|
| Starting ConductR |
|------------------------------------------------|
Extracting ConductR core to /Users/felixsatyaputra/.conductr/images/core
Extracting ConductR agent to /Users/felixsatyaputra/.conductr/images/agent
Starting ConductR core instance on 192.168.10.1..
Starting ConductR core instance on 192.168.10.2..
Starting ConductR core instance on 192.168.10.3..
Waiting for ConductR to start...
Starting ConductR agent instance on 192.168.10.1..
Starting ConductR agent instance on 192.168.10.2..
Starting ConductR agent instance on 192.168.10.3..
|------------------------------------------------|
| Starting OCI-in-Docker support |
|------------------------------------------------|
OCI-in-Docker provided by image lightbend-docker-registry.bintray.io/conductr/oci-in-docker:0.1.0
|------------------------------------------------|
| Starting HAProxy |
|------------------------------------------------|
Exposing the following ports [80, 443, 3000, 5601, 8999, 9000, 9200, 9999]
0c3815403fe7b847356f507ac368614536b40e0e2e7b295c7d6be98f61c4575d
Deploying bundle conductr-haproxy with configuration conductr-haproxy-dev-mode
Retrieving bundle..
Error: bndl: Unable to detect format. Provide a -f or --format argument
```
The error message above is caused by trying to load a bundle called `conductr-haproxy` while there's a local directory called `conductr-haproxy` relative to where `sandbox run` is being called. (Actually in this instance, I'm running the `sandbox run` command from the root of the ConductR project where `conductr-haproxy` directory exists).
The error message above will only appear if the `~/.conductr/cache` is empty.
The above error is caused by the `bndl` command trying to pack `conductr-haproxy` directory.
The possible fix for the above scenario is to tighten the URI resolver around directory detection, i.e. only return directory if it's considered a valid directory by `bndl_utils.detect_format_dir()`
| 0.0 | c8a3c9f17c49c889fcfc09da933c3a3e89b3d96c | [
"conductr_cli/resolvers/test/test_resolvers_util.py::TestResolveBundle::test_is_local_file_with_bundle_conf_dir",
"conductr_cli/resolvers/test/test_resolvers_util.py::TestResolveBundle::test_is_local_file_with_bundle_dir",
"conductr_cli/resolvers/test/test_resolvers_util.py::TestResolveBundle::test_is_local_file_with_empty_dir",
"conductr_cli/resolvers/test/test_resolvers_util.py::TestResolveBundle::test_is_local_file_with_file"
]
| []
| {
"failed_lite_validators": [
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2017-04-24 14:43:17+00:00 | apache-2.0 | 6,140 |
|
typesafehub__conductr-cli-446 | diff --git a/conductr_cli/license_auth.py b/conductr_cli/license_auth.py
index b1d2128..1ab3c67 100644
--- a/conductr_cli/license_auth.py
+++ b/conductr_cli/license_auth.py
@@ -1,5 +1,6 @@
from conductr_cli.constants import DEFAULT_AUTH_TOKEN_FILE
import os
+import sys
try:
import readline
except ImportError:
@@ -7,7 +8,7 @@ except ImportError:
AUTH_TOKEN_PROMPT = '\nAn access token is required. Please visit https://www.lightbend.com/account/access-token to \n' \
- 'obtain one, and a free license or your commercial one.\n' \
+ 'obtain one for free and commercial licenses.\n' \
'\n' \
'Please enter your access token: '
@@ -34,7 +35,10 @@ def prompt_for_auth_token():
readline.clear_history()
try:
- return input(AUTH_TOKEN_PROMPT).strip()
+ if sys.stdin.isatty():
+ return input(AUTH_TOKEN_PROMPT).strip()
+ else:
+ return input().strip()
except EOFError:
return ''
| typesafehub/conductr-cli | 7239e444785144797043e16a9d045e7aa0902783 | diff --git a/conductr_cli/test/test_license_auth.py b/conductr_cli/test/test_license_auth.py
index 727cf24..0c7b5b1 100644
--- a/conductr_cli/test/test_license_auth.py
+++ b/conductr_cli/test/test_license_auth.py
@@ -39,11 +39,25 @@ class TestPromptForAuthToken(TestCase):
mock_input = MagicMock(return_value=auth_token)
with patch('builtins.print', mock_print), \
- patch('builtins.input', mock_input):
+ patch('builtins.input', mock_input), \
+ patch('sys.stdin.isatty', lambda: True):
self.assertEqual(auth_token, license_auth.prompt_for_auth_token())
mock_input.assert_called_once_with(license_auth.AUTH_TOKEN_PROMPT)
+ def test_no_tty_dont_prompt_for_auth_token(self):
+ auth_token = 'test auth token'
+
+ mock_print = MagicMock()
+ mock_input = MagicMock(return_value=auth_token)
+
+ with patch('builtins.print', mock_print), \
+ patch('builtins.input', mock_input), \
+ patch('sys.stdin.isatty', lambda: False):
+ self.assertEqual(auth_token, license_auth.prompt_for_auth_token())
+
+ mock_input.assert_called_once_with()
+
class TestRemoveCachedAuthToken(TestCase):
def test_cached_token_exists(self):
| load-license message not needed?
Encountered this while upgrading conductr cluster from alpha1 to alpha3:
```
conduct load-license -f <<< '...'
An access token is required. Please visit https://www.lightbend.com/account/access-token to
obtain one, and a free license or your commercial one.
Please enter your access token: Loading license into ConductR at 172.31.60.175
Licensed To: 1d1400b6-3e12-45fe-b0cc-15790b5a9b73
Expires In: 364 days (Fri 04 May 2018 01:21AM)
Grants: akka-sbr, cinnamon, conductr
License successfully loaded
```
The initial message is confusing.
1) I'm loading a new access token so the message is out of place to begin with.
2) What does " and a free license or your commercial one" mean? Perhaps just omit that?
| 0.0 | 7239e444785144797043e16a9d045e7aa0902783 | [
"conductr_cli/test/test_license_auth.py::TestPromptForAuthToken::test_no_tty_dont_prompt_for_auth_token"
]
| [
"conductr_cli/test/test_license_auth.py::TestGetCachedAuthToken::test_cached_token_exists",
"conductr_cli/test/test_license_auth.py::TestGetCachedAuthToken::test_cached_token_missing",
"conductr_cli/test/test_license_auth.py::TestPromptForAuthToken::test_prompt_for_auth_token",
"conductr_cli/test/test_license_auth.py::TestRemoveCachedAuthToken::test_cached_token_exists",
"conductr_cli/test/test_license_auth.py::TestRemoveCachedAuthToken::test_cached_token_missing",
"conductr_cli/test/test_license_auth.py::TestSaveAuthToken::test_save_auth_token"
]
| {
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false
} | 2017-05-04 21:18:45+00:00 | apache-2.0 | 6,141 |
|
typesafehub__conductr-cli-466 | diff --git a/conductr_cli/bndl_create.py b/conductr_cli/bndl_create.py
index e5f3cf7..edb06b9 100644
--- a/conductr_cli/bndl_create.py
+++ b/conductr_cli/bndl_create.py
@@ -55,6 +55,7 @@ def bndl_create(args):
mtime = None
bundle_conf_data = b''
runtime_conf_data = b''
+ runtime_conf_str = ''
try:
process_oci = False
@@ -156,19 +157,17 @@ def bndl_create(args):
runtime_conf_path = os.path.join(input_dir, 'runtime-config.sh')
- runtime_conf_str = ''
-
if os.path.exists(runtime_conf_path):
with open(runtime_conf_path, 'r') as runtime_conf_fileobj:
runtime_conf_str = runtime_conf_fileobj.read()
- for env in args.envs if hasattr(args, 'envs') else []:
- if runtime_conf_str:
- runtime_conf_str += '\n'
- runtime_conf_str += 'export \'{}\''.format(env.replace('\'', ''))
-
+ for env in args.envs if hasattr(args, 'envs') else []:
if runtime_conf_str:
- runtime_conf_data = runtime_conf_str.encode('UTF-8')
+ runtime_conf_str += '\n'
+ runtime_conf_str += 'export \'{}\''.format(env.replace('\'', ''))
+
+ if runtime_conf_str:
+ runtime_conf_data = runtime_conf_str.encode('UTF-8')
if not args.name:
try:
| typesafehub/conductr-cli | d6fafba900ac59074dd36f96c7c2221c9f46aef9 | diff --git a/conductr_cli/test/test_bndl_create.py b/conductr_cli/test/test_bndl_create.py
index c477a36..9cdb5df 100644
--- a/conductr_cli/test/test_bndl_create.py
+++ b/conductr_cli/test/test_bndl_create.py
@@ -623,3 +623,52 @@ class TestBndlCreate(CliTestCase):
self.assertTrue(saw_config)
finally:
shutil.rmtree(temp_dir)
+
+ def test_oci_env(self):
+ stdout_mock = MagicMock()
+ tmpdir = tempfile.mkdtemp()
+ tmpfile = os.path.join(tmpdir, 'output')
+
+ try:
+ attributes = create_attributes_object({
+ 'name': 'test',
+ 'source': tmpdir,
+ 'format': 'oci-image',
+ 'image_tag': 'latest',
+ 'output': tmpfile,
+ 'component_description': '',
+ 'use_shazar': True,
+ 'use_default_endpoints': True,
+ 'annotations': [],
+ 'envs': [
+ 'ENV1=123',
+ 'ENV2=456'
+ ]
+ })
+
+ os.mkdir(os.path.join(tmpdir, 'refs'))
+ open(os.path.join(tmpdir, 'oci-layout'), 'w').close()
+ refs = open(os.path.join(tmpdir, 'refs/latest'), 'w')
+ refs.write('{}')
+ refs.close()
+
+ with \
+ patch('sys.stdin', MagicMock(**{'buffer': BytesIO(b'')})), \
+ patch('sys.stdout.buffer.write', stdout_mock):
+ self.assertEqual(bndl_create.bndl_create(attributes), 0)
+
+ self.assertTrue(zipfile.is_zipfile(tmpfile))
+
+ files = {}
+
+ with zipfile.ZipFile(tmpfile) as zip:
+ infos = zip.infolist()
+ for info in infos:
+ files[info.filename] = zip.read(info.filename)
+
+ self.assertEqual(
+ files['test/runtime-config.sh'],
+ b'export \'ENV1=123\'\nexport \'ENV2=456\''
+ )
+ finally:
+ shutil.rmtree(tmpdir)
| `bndl` `runtime-config.sh` manipulation broken for non-conductr bundles
The code for `runtime-config.sh` was placed in the wrong spot and only works for input types of `bundle` currently. Needs fix to ensure that `docker`, `oci-image`, `oci-bundle` inputs can also specifiy `--env` flags. Note that this doesn't apply to `conduct load --env` flags which operate correctly due to the input in that case being `bundle` (a configuration bundle) | 0.0 | d6fafba900ac59074dd36f96c7c2221c9f46aef9 | [
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_oci_env"
]
| [
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_bundle",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_bundle_arg_no_name",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_bundle_conf",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_bundle_conf_dir",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_bundle_conf_no_name",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_bundle_envs",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_bundle_envs_append",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_deterministic_with_shazar",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_deterministic_without_shazar",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_no_format",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_no_ref",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_not_oci",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_with_shazar",
"conductr_cli/test/test_bndl_create.py::TestBndlCreate::test_without_shazar"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2017-05-22 18:32:30+00:00 | apache-2.0 | 6,142 |
|
typesafehub__conductr-cli-484 | diff --git a/conductr_cli/endpoint.py b/conductr_cli/endpoint.py
index b8048f5..4cf8d4c 100644
--- a/conductr_cli/endpoint.py
+++ b/conductr_cli/endpoint.py
@@ -112,7 +112,7 @@ class HttpRequest:
def hocon(self):
request_tree = ConfigTree()
- request_tree.put(self.match if self.match else 'path', self.value)
+ request_tree.put(self.match if self.match else 'path-beg', self.value)
if self.method:
request_tree.put('method', self.method)
if self.rewrite:
| typesafehub/conductr-cli | c91b5dd3bee57bd813dfa26c9724edc13b3ce2c9 | diff --git a/conductr_cli/test/test_bndl_utils.py b/conductr_cli/test/test_bndl_utils.py
index 70ab43c..72c200b 100644
--- a/conductr_cli/test/test_bndl_utils.py
+++ b/conductr_cli/test/test_bndl_utils.py
@@ -434,7 +434,7 @@ class TestBndlUtils(CliTestCase):
| http {
| requests = [
| {
- | path = "/"
+ | path-beg = "/"
| }
| ]
| }
| bndl endpoint should default to --path-beg | 0.0 | c91b5dd3bee57bd813dfa26c9724edc13b3ce2c9 | [
"conductr_cli/test/test_bndl_utils.py::TestBndlUtils::test_load_bundle_args_into_conf"
]
| [
"conductr_cli/test/test_bndl_utils.py::TestBndlUtils::test_detect_format_dir",
"conductr_cli/test/test_bndl_utils.py::TestBndlUtils::test_detect_format_stream",
"conductr_cli/test/test_bndl_utils.py::TestBndlUtils::test_digest_reader_writer",
"conductr_cli/test/test_bndl_utils.py::TestBndlUtils::test_first_mtime",
"conductr_cli/test/test_bndl_utils.py::TestBndlUtils::test_load_bundle_args_into_conf_with_generic_defaults",
"conductr_cli/test/test_bndl_utils.py::TestBndlUtils::test_load_bundle_args_into_conf_with_play_defaults"
]
| {
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false
} | 2017-06-05 13:40:46+00:00 | apache-2.0 | 6,143 |
|
typesafehub__conductr-cli-513 | diff --git a/1 b/1
new file mode 100644
index 0000000..e69de29
diff --git a/conductr_cli/__init__.py b/conductr_cli/__init__.py
index 7311807..dee93a9 100644
--- a/conductr_cli/__init__.py
+++ b/conductr_cli/__init__.py
@@ -1,1 +1,1 @@
-__version__ = '1.2.15'
+__version__ = '1.2.16'
diff --git a/conductr_cli/main_handler.py b/conductr_cli/main_handler.py
index 2f4056a..fc0cc8e 100644
--- a/conductr_cli/main_handler.py
+++ b/conductr_cli/main_handler.py
@@ -11,6 +11,7 @@ SUPPORTED_PYTHON_VERSION = (3, 4)
def run(callback):
try:
enforce_python_version()
+ enforce_cwd_exists()
result = callback()
return result
except KeyboardInterrupt:
@@ -46,6 +47,14 @@ def run(callback):
sys.exit(1)
+def enforce_cwd_exists():
+ try:
+ os.getcwd()
+ except FileNotFoundError:
+ sys.exit('Unable to start CLI due to missing current/working directory.\n'
+ 'Change into a new directory and try again.\n')
+
+
def enforce_python_version():
if sys.version_info < SUPPORTED_PYTHON_VERSION:
major, minor, micro, release_level, serial = sys.version_info
diff --git a/conductr_cli/resolvers/bintray_resolver.py b/conductr_cli/resolvers/bintray_resolver.py
index 4501b87..b01da9e 100644
--- a/conductr_cli/resolvers/bintray_resolver.py
+++ b/conductr_cli/resolvers/bintray_resolver.py
@@ -15,7 +15,7 @@ BINTRAY_API_BASE_URL = 'https://api.bintray.com'
BINTRAY_DOWNLOAD_BASE_URL = 'https://dl.bintray.com'
BINTRAY_DOWNLOAD_REALM = 'Bintray'
BINTRAY_CREDENTIAL_FILE_PATH = '{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~'))
-BINTRAY_PROPERTIES_RE = re.compile('^\s*(\S+)\s*=\s*([\S]+)\s*$')
+BINTRAY_PROPERTIES_RE = re.compile('^\s*(\S+)\s*=\s*((\S|\S+\s+\S+)+)\s*$')
BINTRAY_LIGHTBEND_ORG = 'lightbend'
BINTRAY_CONDUCTR_COMMERCIAL_REPO = 'commercial-releases'
BINTRAY_CONDUCTR_GENERIC_REPO = 'generic'
@@ -168,12 +168,16 @@ def load_bintray_credentials(raise_error=True, disable_instructions=False):
with open(BINTRAY_CREDENTIAL_FILE_PATH, 'r') as cred_file:
lines = [line.replace('\n', '') for line in cred_file.readlines()]
data = dict()
+ realm = BINTRAY_DOWNLOAD_REALM
for line in lines:
match = BINTRAY_PROPERTIES_RE.match(line)
if match is not None:
try:
key, value = match.group(1, 2)
- data[key] = value
+ if key == 'realm':
+ realm = value
+ elif realm == BINTRAY_DOWNLOAD_REALM:
+ data[key] = value
except IndexError:
pass
| typesafehub/conductr-cli | 5d05e5dec17319326326f78453465829b55fb446 | diff --git a/conductr_cli/resolvers/test/test_bintray_resolver.py b/conductr_cli/resolvers/test/test_bintray_resolver.py
index 4790058..9cc48c3 100644
--- a/conductr_cli/resolvers/test/test_bintray_resolver.py
+++ b/conductr_cli/resolvers/test/test_bintray_resolver.py
@@ -1018,6 +1018,29 @@ class TestLoadBintrayCredentials(TestCase):
exists_mock.assert_called_with('{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~')))
open_mock.assert_called_with('{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~')), 'r')
+ def test_success_multiple_realms(self):
+ bintray_credential_file = (
+ 'realm = Bintray\n'
+ 'user = user1\n'
+ 'password = sec=ret\n'
+ 'realm = Bintray API Realm\n'
+ 'user = user2\n'
+ 'password = sec=ret2\n'
+ )
+
+ exists_mock = MagicMock(return_value=True)
+ open_mock = MagicMock(return_value=io.StringIO(bintray_credential_file))
+
+ with patch('os.path.exists', exists_mock), \
+ patch('builtins.open', open_mock):
+ realm, username, password = bintray_resolver.load_bintray_credentials()
+ self.assertEqual('Bintray', realm)
+ self.assertEqual('user1', username)
+ self.assertEqual('sec=ret', password)
+
+ exists_mock.assert_called_with('{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~')))
+ open_mock.assert_called_with('{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~')), 'r')
+
def test_credential_file_not_having_username_password(self):
bintray_credential_file = strip_margin(
"""|dummy = yes
| Working directory being unlinked causes failure
When a working directory has been unlinked, the CLI fails to operate:
Reproduce:
```bash
$ mkdir ~/testing-dir && cd ~/testing-dir && rm -r ~/testing-dir && conduct load visualizer
sh: 0: getcwd() failed: No such file or directory
Retrieving bundle..
Loading bundle from cache typesafe/bundle/visualizer
Bintray credentials loaded from /home/longshorej/.lightbend/commercial.credentials
Error: Encountered unexpected error.
Error: Reason: FileNotFoundError [Errno 2] No such file or directory
Error: Further information of the error can be found in the error log file: /home/longshorej/.conductr/errors.log
-> 1
```
Stack trace:
```bash
2017-06-21 10:19:31,962: Failure running the following command: ['/home/longshorej/.local/bin/conduct', 'load', 'visualizer']
Traceback (most recent call last):
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/main_handler.py", line 14, in run
result = callback()
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/conduct.py", line 35, in main_method
conduct_main.run()
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/conduct_main.py", line 610, in run
is_completed_without_error = args.func(args)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 43, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 59, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 99, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 116, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 136, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 152, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 198, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 222, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 238, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 256, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 428, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/validation.py", line 464, in handler
return func(*args, **kwargs)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/conduct_load.py", line 71, in load
return load_v2(args)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/conduct_load.py", line 249, in load_v2
args.bundle, args.offline_mode)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/resolver.py", line 28, in resolve_bundle
is_resolved, bundle_file_name, bundle_file, error = resolver.resolve_bundle(cache_dir, uri)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/resolvers/uri_resolver.py", line 17, in resolve_bundle
return resolve_file(cache_dir, uri, auth)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/resolvers/uri_resolver.py", line 28, in resolve_file
file_name, file_url = get_url(uri)
File "/home/longshorej/work/lightbend/conductr-cli/conductr_cli/resolvers/uri_resolver.py", line 91, in get_url
np = str(op.cwd() / op)
File "/usr/lib/python3.5/pathlib.py", line 1023, in cwd
return cls(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory
``` | 0.0 | 5d05e5dec17319326326f78453465829b55fb446 | [
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_success_multiple_realms"
]
| [
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_bintray_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_bintray_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_failure_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_failure_http_error_repo_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_failure_malformed_bundle_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_bintray_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_bintray_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_failure_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_failure_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_failure_http_error_repo_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_failure_malformed_bundle_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_bintray_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_bintray_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_bundle",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_failure_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_failure_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_failure_http_error_repo_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_failure_malformed_bundle_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_file",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_file_exists_but_no_conf_do_bintray",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_bintray_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_bintray_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_failure_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_failure_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_failure_http_error_repo_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_failure_malformed_bundle_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_file",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersion::test_failure_multiple_versions_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersion::test_failure_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersion::test_success",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatest::test_failure_latest_version_malformed",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatest::test_latest_version_from_attribute_names",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatest::test_latest_version_from_attribute_names_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatest::test_success",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatestCompatibilityVersion::test_no_version",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatestCompatibilityVersion::test_success",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_malformed_bundle_uri_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_resolved_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_resolved_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestContinuousDeliveryUri::test_return_none_if_input_is_from_different_resolver",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestContinuousDeliveryUri::test_return_none_if_input_is_invalid",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestContinuousDeliveryUri::test_return_none_if_input_is_none",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestContinuousDeliveryUri::test_return_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_credential_file_not_having_username_password",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_missing_credential_file",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_success",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_success_whitespace",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestGetJson::test_get_json",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestGetJson::test_get_json_missing_password",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestGetJson::test_get_json_missing_username",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestGetJson::test_get_json_no_credentials",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestSupportedSchemes::test_supported_schemes"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2017-06-28 20:52:00+00:00 | apache-2.0 | 6,144 |
|
typesafehub__conductr-cli-514 | diff --git a/1 b/1
new file mode 100644
index 0000000..e69de29
diff --git a/conductr_cli/resolvers/bintray_resolver.py b/conductr_cli/resolvers/bintray_resolver.py
index 4501b87..b01da9e 100644
--- a/conductr_cli/resolvers/bintray_resolver.py
+++ b/conductr_cli/resolvers/bintray_resolver.py
@@ -15,7 +15,7 @@ BINTRAY_API_BASE_URL = 'https://api.bintray.com'
BINTRAY_DOWNLOAD_BASE_URL = 'https://dl.bintray.com'
BINTRAY_DOWNLOAD_REALM = 'Bintray'
BINTRAY_CREDENTIAL_FILE_PATH = '{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~'))
-BINTRAY_PROPERTIES_RE = re.compile('^\s*(\S+)\s*=\s*([\S]+)\s*$')
+BINTRAY_PROPERTIES_RE = re.compile('^\s*(\S+)\s*=\s*((\S|\S+\s+\S+)+)\s*$')
BINTRAY_LIGHTBEND_ORG = 'lightbend'
BINTRAY_CONDUCTR_COMMERCIAL_REPO = 'commercial-releases'
BINTRAY_CONDUCTR_GENERIC_REPO = 'generic'
@@ -168,12 +168,16 @@ def load_bintray_credentials(raise_error=True, disable_instructions=False):
with open(BINTRAY_CREDENTIAL_FILE_PATH, 'r') as cred_file:
lines = [line.replace('\n', '') for line in cred_file.readlines()]
data = dict()
+ realm = BINTRAY_DOWNLOAD_REALM
for line in lines:
match = BINTRAY_PROPERTIES_RE.match(line)
if match is not None:
try:
key, value = match.group(1, 2)
- data[key] = value
+ if key == 'realm':
+ realm = value
+ elif realm == BINTRAY_DOWNLOAD_REALM:
+ data[key] = value
except IndexError:
pass
| typesafehub/conductr-cli | 5d05e5dec17319326326f78453465829b55fb446 | diff --git a/conductr_cli/resolvers/test/test_bintray_resolver.py b/conductr_cli/resolvers/test/test_bintray_resolver.py
index 4790058..9cc48c3 100644
--- a/conductr_cli/resolvers/test/test_bintray_resolver.py
+++ b/conductr_cli/resolvers/test/test_bintray_resolver.py
@@ -1018,6 +1018,29 @@ class TestLoadBintrayCredentials(TestCase):
exists_mock.assert_called_with('{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~')))
open_mock.assert_called_with('{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~')), 'r')
+ def test_success_multiple_realms(self):
+ bintray_credential_file = (
+ 'realm = Bintray\n'
+ 'user = user1\n'
+ 'password = sec=ret\n'
+ 'realm = Bintray API Realm\n'
+ 'user = user2\n'
+ 'password = sec=ret2\n'
+ )
+
+ exists_mock = MagicMock(return_value=True)
+ open_mock = MagicMock(return_value=io.StringIO(bintray_credential_file))
+
+ with patch('os.path.exists', exists_mock), \
+ patch('builtins.open', open_mock):
+ realm, username, password = bintray_resolver.load_bintray_credentials()
+ self.assertEqual('Bintray', realm)
+ self.assertEqual('user1', username)
+ self.assertEqual('sec=ret', password)
+
+ exists_mock.assert_called_with('{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~')))
+ open_mock.assert_called_with('{}/.lightbend/commercial.credentials'.format(os.path.expanduser('~')), 'r')
+
def test_credential_file_not_having_username_password(self):
bintray_credential_file = strip_margin(
"""|dummy = yes
| Credentials file can only contain one section
My credentials file are defined as follows:
$ cat .lightbend/commercial.credentials
realm = Bintray
host = dl.bintray.com
user = [my username]
password = [my password]
realm = Bintray API Realm
host = api.bintray.com
user = [csp user]
password = [csp password]
I took the template from https://github.com/yuchaoran2011/csp-provisioning/blob/master/csp-environment/ansible/roles/install_conductr_cli/templates/commercial.credentials.j2
But when I ran:
`sandbox run 2.1.1 --feature visualization`,
I got the following error:
|------------------------------------------------|
| Starting ConductR |
|------------------------------------------------|
Bintray credentials loaded from /home/ubuntu/.lightbend/commercial.credentials
Error: Unable to fetch ConductR core artifact 2.1.1 from Bintray.
Error: Please specify a valid ConductR version.
Error: The latest version can be found on: https://www.lightbend.com/product/conductr/developer
Removing the last 4 lines of the credentials file solved the problem for me. | 0.0 | 5d05e5dec17319326326f78453465829b55fb446 | [
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_success_multiple_realms"
]
| [
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_bintray_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_bintray_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_failure_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_failure_http_error_repo_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundle::test_failure_malformed_bundle_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_bintray_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_bintray_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_failure_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_failure_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_failure_http_error_repo_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleConfiguration::test_failure_malformed_bundle_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_bintray_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_bintray_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_bundle",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_failure_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_failure_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_failure_http_error_repo_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_failure_malformed_bundle_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_file",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleFromCache::test_file_exists_but_no_conf_do_bintray",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_bintray_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_bintray_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_failure_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_failure_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_failure_http_error_repo_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_failure_malformed_bundle_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBundleConfigurationFromCache::test_file",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersion::test_failure_multiple_versions_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersion::test_failure_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersion::test_success",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatest::test_failure_latest_version_malformed",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatest::test_latest_version_from_attribute_names",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatest::test_latest_version_from_attribute_names_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatest::test_success",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatestCompatibilityVersion::test_no_version",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestBintrayResolveVersionLatestCompatibilityVersion::test_success",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_connection_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_http_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_malformed_bundle_uri_error",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_resolved_version_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestResolveBundleVersion::test_resolved_version_not_found",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestContinuousDeliveryUri::test_return_none_if_input_is_from_different_resolver",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestContinuousDeliveryUri::test_return_none_if_input_is_invalid",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestContinuousDeliveryUri::test_return_none_if_input_is_none",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestContinuousDeliveryUri::test_return_uri",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_credential_file_not_having_username_password",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_missing_credential_file",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_success",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestLoadBintrayCredentials::test_success_whitespace",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestGetJson::test_get_json",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestGetJson::test_get_json_missing_password",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestGetJson::test_get_json_missing_username",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestGetJson::test_get_json_no_credentials",
"conductr_cli/resolvers/test/test_bintray_resolver.py::TestSupportedSchemes::test_supported_schemes"
]
| {
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false
} | 2017-06-28 21:40:49+00:00 | apache-2.0 | 6,145 |
|
typesafehub__conductr-cli-538 | diff --git a/conductr_cli/host.py b/conductr_cli/host.py
index e7974af..e50f1a7 100644
--- a/conductr_cli/host.py
+++ b/conductr_cli/host.py
@@ -83,6 +83,15 @@ def is_listening(ip_addr, port):
return result
+def alias_number(addr):
+ if addr.version == 4:
+ return int(addr.exploded.split('.')[-1], 10) - 1
+ elif addr.version == 6:
+ return int(addr.exploded.split(':')[-1], 16) - 1
+ else:
+ raise ValueError('version must be 4 or 6, given {}'.format(addr.version))
+
+
def addr_alias_commands(addrs, ip_version):
if_name = loopback_device_name()
@@ -90,7 +99,7 @@ def addr_alias_commands(addrs, ip_version):
commands = []
if is_linux():
- commands = [['sudo', 'ifconfig', '{}:{}'.format(if_name, int(addr.exploded[-1:]) - 1),
+ commands = [['sudo', 'ifconfig', '{}:{}'.format(if_name, alias_number(addr)),
addr.exploded, 'netmask', subnet_mask, 'up'] for addr in addrs]
elif is_macos():
commands = [['sudo', 'ifconfig', if_name, 'alias', addr.exploded, subnet_mask] for addr in addrs]
diff --git a/conductr_cli/terminal.py b/conductr_cli/terminal.py
index 2c27df4..84205cb 100644
--- a/conductr_cli/terminal.py
+++ b/conductr_cli/terminal.py
@@ -28,7 +28,9 @@ def docker_inspect(container_id, inspect_format=None):
def docker_run(optional_args, image, positional_args):
cmd = ['docker', 'run'] + optional_args + [image] + positional_args
- return subprocess.call(cmd)
+ status = subprocess.call(cmd)
+ assert status == 0, 'docker exited with {}'.format(status)
+ return 0
def docker_rm(containers):
| typesafehub/conductr-cli | 2df68846f22c4ab568e7430d19920617e52d0d62 | diff --git a/conductr_cli/test/test_host.py b/conductr_cli/test/test_host.py
index 380225c..2a9aef8 100644
--- a/conductr_cli/test/test_host.py
+++ b/conductr_cli/test/test_host.py
@@ -254,6 +254,51 @@ class TestAddrAliasCommands(TestCase):
mock_is_linux.assert_called_once_with()
mock_is_macos.assert_not_called()
+ def test_linux_ipv4_large(self):
+ mock_loopback_device_name = MagicMock(return_value=self.loopback_device_name)
+ mock_is_linux = MagicMock(return_value=True)
+ mock_is_macos = MagicMock(return_value=False)
+
+ with patch('conductr_cli.host.loopback_device_name', mock_loopback_device_name), \
+ patch('conductr_cli.host.is_linux', mock_is_linux), \
+ patch('conductr_cli.host.is_macos', mock_is_macos):
+ result = host.addr_alias_commands([
+ ipaddress.ip_address('192.168.1.1'),
+ ipaddress.ip_address('192.168.1.2'),
+ ipaddress.ip_address('192.168.1.3'),
+ ipaddress.ip_address('192.168.1.4'),
+ ipaddress.ip_address('192.168.1.5'),
+ ipaddress.ip_address('192.168.1.6'),
+ ipaddress.ip_address('192.168.1.7'),
+ ipaddress.ip_address('192.168.1.8'),
+ ipaddress.ip_address('192.168.1.9'),
+ ipaddress.ip_address('192.168.1.10'),
+ ipaddress.ip_address('192.168.1.11'),
+ ipaddress.ip_address('192.168.1.12'),
+ ipaddress.ip_address('192.168.1.13')
+ ], 4)
+
+ expected_result = [
+ ['sudo', 'ifconfig', 'ix0:0', '192.168.1.1', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:1', '192.168.1.2', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:2', '192.168.1.3', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:3', '192.168.1.4', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:4', '192.168.1.5', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:5', '192.168.1.6', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:6', '192.168.1.7', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:7', '192.168.1.8', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:8', '192.168.1.9', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:9', '192.168.1.10', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:10', '192.168.1.11', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:11', '192.168.1.12', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:12', '192.168.1.13', 'netmask', '255.255.255.255', 'up']
+ ]
+ self.assertEqual(expected_result, result)
+
+ mock_loopback_device_name.assert_called_once_with()
+ mock_is_linux.assert_called_once_with()
+ mock_is_macos.assert_not_called()
+
def test_linux_ipv6(self):
mock_loopback_device_name = MagicMock(return_value=self.loopback_device_name)
mock_is_linux = MagicMock(return_value=True)
@@ -265,8 +310,8 @@ class TestAddrAliasCommands(TestCase):
result = host.addr_alias_commands(self.addrs_ipv6, 6)
expected_result = [
- ['sudo', 'ifconfig', 'ix0:0', '0000:0000:0000:0000:0000:ffff:c0a8:0101', 'netmask', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'up'],
- ['sudo', 'ifconfig', 'ix0:1', '0000:0000:0000:0000:0000:ffff:c0a8:0102', 'netmask', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'up']
+ ['sudo', 'ifconfig', 'ix0:256', '0000:0000:0000:0000:0000:ffff:c0a8:0101', 'netmask', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'up'],
+ ['sudo', 'ifconfig', 'ix0:257', '0000:0000:0000:0000:0000:ffff:c0a8:0102', 'netmask', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'up']
]
self.assertEqual(expected_result, result)
diff --git a/conductr_cli/test/test_terminal.py b/conductr_cli/test/test_terminal.py
index d6ff783..0337492 100644
--- a/conductr_cli/test/test_terminal.py
+++ b/conductr_cli/test/test_terminal.py
@@ -72,7 +72,7 @@ class TestTerminal(CliTestCase):
image = 'image:version'
positional_args = ['--discover-host-ip']
stdout = MagicMock()
- subprocess_call_mock = MagicMock()
+ subprocess_call_mock = MagicMock(return_value=0)
with patch('subprocess.call', subprocess_call_mock), \
patch('sys.stdout', stdout):
@@ -81,6 +81,21 @@ class TestTerminal(CliTestCase):
self.assertEqual('', self.output(stdout))
subprocess_call_mock.assert_called_with(['docker', 'run'] + optional_args + [image] + positional_args)
+ def test_docker_run_fail(self):
+ optional_args = ['-p', '9001:9001', '-e', 'AKKA_LOGLEVEL=info']
+ image = 'image:version'
+ positional_args = ['--discover-host-ip']
+ stdout = MagicMock()
+ subprocess_call_mock = MagicMock(return_value=1)
+
+ with patch('subprocess.call', subprocess_call_mock), \
+ patch('sys.stdout', stdout), \
+ self.assertRaises(AssertionError):
+ terminal.docker_run(optional_args, image, positional_args)
+
+ self.assertEqual('', self.output(stdout))
+ subprocess_call_mock.assert_called_with(['docker', 'run'] + optional_args + [image] + positional_args)
+
def test_docker_rm(self):
containers = ['cond-0', 'cond-1']
stdout = MagicMock()
| Sandbox startup failing to start haproxy doesn't result in error
* Run a program that binds on port 9000
* Start the sandbox. Notice docker complains, but the sandbox doesn't notice.
We should fail fast and tell the user about the `--bundle-http-port` flag / `BUNDLE_HTTP_PORT` env variable | 0.0 | 2df68846f22c4ab568e7430d19920617e52d0d62 | [
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_linux_ipv4_large",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_linux_ipv6",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_run_fail"
]
| [
"conductr_cli/test/test_host.py::TestResolveDefaultHost::test_resolve",
"conductr_cli/test/test_host.py::TestResolveDefaultIp::test_resolve_from_addr_range",
"conductr_cli/test/test_host.py::TestResolveDefaultIp::test_resolve_from_docker",
"conductr_cli/test/test_host.py::TestResolveHostFromEnv::test_conductr_host_env_set",
"conductr_cli/test/test_host.py::TestResolveHostFromEnv::test_conductr_ip_env_set",
"conductr_cli/test/test_host.py::TestResolveHostFromEnv::test_no_env_set",
"conductr_cli/test/test_host.py::TestLoopbackDeviceName::test_linux",
"conductr_cli/test/test_host.py::TestLoopbackDeviceName::test_macos",
"conductr_cli/test/test_host.py::TestOsDetect::test_linux",
"conductr_cli/test/test_host.py::TestOsDetect::test_macos",
"conductr_cli/test/test_host.py::TestCanBind::test_failure",
"conductr_cli/test/test_host.py::TestCanBind::test_success_ipv4",
"conductr_cli/test/test_host.py::TestCanBind::test_success_ipv6",
"conductr_cli/test/test_host.py::TestIsListening::test_listening_ipv4",
"conductr_cli/test/test_host.py::TestIsListening::test_listening_ipv6",
"conductr_cli/test/test_host.py::TestIsListening::test_not_listening",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_linux_ipv4",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_linux_with_bound_addresses",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_macos_ipv4",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_macos_ipv6",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_macos_with_bound_address",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_single_addr",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_unknown_ipv4",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_unknown_ipv6",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_images",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_info",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_inspect",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_ps",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_pull",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_rm",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_run"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false
} | 2017-08-10 19:02:46+00:00 | apache-2.0 | 6,146 |
|
typesafehub__conductr-cli-540 | diff --git a/conductr_cli/conductr_backup.py b/conductr_cli/conductr_backup.py
index e8d3d3f..04b515d 100644
--- a/conductr_cli/conductr_backup.py
+++ b/conductr_cli/conductr_backup.py
@@ -61,12 +61,18 @@ def backup(args):
backup_agents(args, backup_directory)
compress_backup(args.output_path, backup_directory)
-
finally:
remove_backup_directory(backup_directory)
+ return True
def compress_backup(output_path, backup_directory):
+ log = logging.getLogger(__name__)
+
+ if sys.stdout.isatty() and output_path is None:
+ log.error('conduct backup: Refusing to write to terminal. Provide -o or redirect elsewhere')
+ sys.exit(2)
+
output_file = open(output_path, 'wb') if output_path else sys.stdout.buffer
with tempfile.NamedTemporaryFile() as zip_file_data:
with zipfile.ZipFile(zip_file_data, 'w') as zip_file:
diff --git a/conductr_cli/host.py b/conductr_cli/host.py
index e7974af..e50f1a7 100644
--- a/conductr_cli/host.py
+++ b/conductr_cli/host.py
@@ -83,6 +83,15 @@ def is_listening(ip_addr, port):
return result
+def alias_number(addr):
+ if addr.version == 4:
+ return int(addr.exploded.split('.')[-1], 10) - 1
+ elif addr.version == 6:
+ return int(addr.exploded.split(':')[-1], 16) - 1
+ else:
+ raise ValueError('version must be 4 or 6, given {}'.format(addr.version))
+
+
def addr_alias_commands(addrs, ip_version):
if_name = loopback_device_name()
@@ -90,7 +99,7 @@ def addr_alias_commands(addrs, ip_version):
commands = []
if is_linux():
- commands = [['sudo', 'ifconfig', '{}:{}'.format(if_name, int(addr.exploded[-1:]) - 1),
+ commands = [['sudo', 'ifconfig', '{}:{}'.format(if_name, alias_number(addr)),
addr.exploded, 'netmask', subnet_mask, 'up'] for addr in addrs]
elif is_macos():
commands = [['sudo', 'ifconfig', if_name, 'alias', addr.exploded, subnet_mask] for addr in addrs]
diff --git a/conductr_cli/terminal.py b/conductr_cli/terminal.py
index 2c27df4..84205cb 100644
--- a/conductr_cli/terminal.py
+++ b/conductr_cli/terminal.py
@@ -28,7 +28,9 @@ def docker_inspect(container_id, inspect_format=None):
def docker_run(optional_args, image, positional_args):
cmd = ['docker', 'run'] + optional_args + [image] + positional_args
- return subprocess.call(cmd)
+ status = subprocess.call(cmd)
+ assert status == 0, 'docker exited with {}'.format(status)
+ return 0
def docker_rm(containers):
| typesafehub/conductr-cli | 2df68846f22c4ab568e7430d19920617e52d0d62 | diff --git a/conductr_cli/test/test_host.py b/conductr_cli/test/test_host.py
index 380225c..2a9aef8 100644
--- a/conductr_cli/test/test_host.py
+++ b/conductr_cli/test/test_host.py
@@ -254,6 +254,51 @@ class TestAddrAliasCommands(TestCase):
mock_is_linux.assert_called_once_with()
mock_is_macos.assert_not_called()
+ def test_linux_ipv4_large(self):
+ mock_loopback_device_name = MagicMock(return_value=self.loopback_device_name)
+ mock_is_linux = MagicMock(return_value=True)
+ mock_is_macos = MagicMock(return_value=False)
+
+ with patch('conductr_cli.host.loopback_device_name', mock_loopback_device_name), \
+ patch('conductr_cli.host.is_linux', mock_is_linux), \
+ patch('conductr_cli.host.is_macos', mock_is_macos):
+ result = host.addr_alias_commands([
+ ipaddress.ip_address('192.168.1.1'),
+ ipaddress.ip_address('192.168.1.2'),
+ ipaddress.ip_address('192.168.1.3'),
+ ipaddress.ip_address('192.168.1.4'),
+ ipaddress.ip_address('192.168.1.5'),
+ ipaddress.ip_address('192.168.1.6'),
+ ipaddress.ip_address('192.168.1.7'),
+ ipaddress.ip_address('192.168.1.8'),
+ ipaddress.ip_address('192.168.1.9'),
+ ipaddress.ip_address('192.168.1.10'),
+ ipaddress.ip_address('192.168.1.11'),
+ ipaddress.ip_address('192.168.1.12'),
+ ipaddress.ip_address('192.168.1.13')
+ ], 4)
+
+ expected_result = [
+ ['sudo', 'ifconfig', 'ix0:0', '192.168.1.1', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:1', '192.168.1.2', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:2', '192.168.1.3', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:3', '192.168.1.4', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:4', '192.168.1.5', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:5', '192.168.1.6', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:6', '192.168.1.7', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:7', '192.168.1.8', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:8', '192.168.1.9', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:9', '192.168.1.10', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:10', '192.168.1.11', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:11', '192.168.1.12', 'netmask', '255.255.255.255', 'up'],
+ ['sudo', 'ifconfig', 'ix0:12', '192.168.1.13', 'netmask', '255.255.255.255', 'up']
+ ]
+ self.assertEqual(expected_result, result)
+
+ mock_loopback_device_name.assert_called_once_with()
+ mock_is_linux.assert_called_once_with()
+ mock_is_macos.assert_not_called()
+
def test_linux_ipv6(self):
mock_loopback_device_name = MagicMock(return_value=self.loopback_device_name)
mock_is_linux = MagicMock(return_value=True)
@@ -265,8 +310,8 @@ class TestAddrAliasCommands(TestCase):
result = host.addr_alias_commands(self.addrs_ipv6, 6)
expected_result = [
- ['sudo', 'ifconfig', 'ix0:0', '0000:0000:0000:0000:0000:ffff:c0a8:0101', 'netmask', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'up'],
- ['sudo', 'ifconfig', 'ix0:1', '0000:0000:0000:0000:0000:ffff:c0a8:0102', 'netmask', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'up']
+ ['sudo', 'ifconfig', 'ix0:256', '0000:0000:0000:0000:0000:ffff:c0a8:0101', 'netmask', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'up'],
+ ['sudo', 'ifconfig', 'ix0:257', '0000:0000:0000:0000:0000:ffff:c0a8:0102', 'netmask', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', 'up']
]
self.assertEqual(expected_result, result)
diff --git a/conductr_cli/test/test_terminal.py b/conductr_cli/test/test_terminal.py
index d6ff783..0337492 100644
--- a/conductr_cli/test/test_terminal.py
+++ b/conductr_cli/test/test_terminal.py
@@ -72,7 +72,7 @@ class TestTerminal(CliTestCase):
image = 'image:version'
positional_args = ['--discover-host-ip']
stdout = MagicMock()
- subprocess_call_mock = MagicMock()
+ subprocess_call_mock = MagicMock(return_value=0)
with patch('subprocess.call', subprocess_call_mock), \
patch('sys.stdout', stdout):
@@ -81,6 +81,21 @@ class TestTerminal(CliTestCase):
self.assertEqual('', self.output(stdout))
subprocess_call_mock.assert_called_with(['docker', 'run'] + optional_args + [image] + positional_args)
+ def test_docker_run_fail(self):
+ optional_args = ['-p', '9001:9001', '-e', 'AKKA_LOGLEVEL=info']
+ image = 'image:version'
+ positional_args = ['--discover-host-ip']
+ stdout = MagicMock()
+ subprocess_call_mock = MagicMock(return_value=1)
+
+ with patch('subprocess.call', subprocess_call_mock), \
+ patch('sys.stdout', stdout), \
+ self.assertRaises(AssertionError):
+ terminal.docker_run(optional_args, image, positional_args)
+
+ self.assertEqual('', self.output(stdout))
+ subprocess_call_mock.assert_called_with(['docker', 'run'] + optional_args + [image] + positional_args)
+
def test_docker_rm(self):
containers = ['cond-0', 'cond-1']
stdout = MagicMock()
| `conduct backup` prints to TTY
When using `conduct backup`, it should do a TTY check similar to this to ensure that we don't print "garbage" to the TTY:
https://github.com/typesafehub/conductr-cli/blob/master/conductr_cli/bndl_main.py#L34-L36
So I'd expect behavior like this:
Failure:
```bash
$ conduct backup
conduct: Refusing to write to terminal. Provide -o or redirect elsewhere
-> 2
```
Success:
```bash
$ conduct backup > my-file
-> 0
``` | 0.0 | 2df68846f22c4ab568e7430d19920617e52d0d62 | [
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_linux_ipv4_large",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_linux_ipv6",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_run_fail"
]
| [
"conductr_cli/test/test_host.py::TestResolveDefaultHost::test_resolve",
"conductr_cli/test/test_host.py::TestResolveDefaultIp::test_resolve_from_addr_range",
"conductr_cli/test/test_host.py::TestResolveDefaultIp::test_resolve_from_docker",
"conductr_cli/test/test_host.py::TestResolveHostFromEnv::test_conductr_host_env_set",
"conductr_cli/test/test_host.py::TestResolveHostFromEnv::test_conductr_ip_env_set",
"conductr_cli/test/test_host.py::TestResolveHostFromEnv::test_no_env_set",
"conductr_cli/test/test_host.py::TestLoopbackDeviceName::test_linux",
"conductr_cli/test/test_host.py::TestLoopbackDeviceName::test_macos",
"conductr_cli/test/test_host.py::TestOsDetect::test_linux",
"conductr_cli/test/test_host.py::TestOsDetect::test_macos",
"conductr_cli/test/test_host.py::TestCanBind::test_failure",
"conductr_cli/test/test_host.py::TestCanBind::test_success_ipv4",
"conductr_cli/test/test_host.py::TestCanBind::test_success_ipv6",
"conductr_cli/test/test_host.py::TestIsListening::test_listening_ipv4",
"conductr_cli/test/test_host.py::TestIsListening::test_listening_ipv6",
"conductr_cli/test/test_host.py::TestIsListening::test_not_listening",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_linux_ipv4",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_linux_with_bound_addresses",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_macos_ipv4",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_macos_ipv6",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_macos_with_bound_address",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_single_addr",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_unknown_ipv4",
"conductr_cli/test/test_host.py::TestAddrAliasCommands::test_unknown_ipv6",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_images",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_info",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_inspect",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_ps",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_pull",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_rm",
"conductr_cli/test/test_terminal.py::TestTerminal::test_docker_run"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false
} | 2017-08-10 21:02:00+00:00 | apache-2.0 | 6,147 |
|
ubclaunchpad__mimic-24 | diff --git a/mimic/text_generator_factory.py b/mimic/text_generator_factory.py
new file mode 100644
index 0000000..a68a814
--- /dev/null
+++ b/mimic/text_generator_factory.py
@@ -0,0 +1,23 @@
+"""text generator creator module."""
+from mimic.model.model import Model
+from mimic.model.markov_chain_model import MarkovChainModel
+from mimic.text_generator import TextGenerator
+
+
+class TextGeneratorFactory:
+ """
+ TextGeneratorFactory class.
+
+ Class that creates TextGenerators with the choice of a model for the user.
+ """
+
+ def __init__(self):
+ """Initialize a TextGenerator with the given model type."""
+
+ def create_markov_chain_text_generator(self):
+ """Create a TextGenerator using a markov chain model."""
+ return TextGenerator(MarkovChainModel())
+
+ def create_LTSM_text_generator(self):
+ """Create a TextGenerator using a LTSM model."""
+ raise NotImplementedError
| ubclaunchpad/mimic | 2b432039b993c7466903ac2e0e1c4d1ca4ab062a | diff --git a/mimic/tests/test_text_generator_factory.py b/mimic/tests/test_text_generator_factory.py
new file mode 100644
index 0000000..f45f0a2
--- /dev/null
+++ b/mimic/tests/test_text_generator_factory.py
@@ -0,0 +1,20 @@
+import unittest
+from mimic.text_generator import TextGenerator
+from mimic.text_generator_factory import TextGeneratorFactory
+
+
+class TestTextGeneratorFactory(unittest.TestCase):
+
+ def setUp(self):
+ self.textGeneratorFactory = TextGeneratorFactory()
+
+ def test_create_markov_chain_text_generator(self):
+ factory = self.textGeneratorFactory
+ testGenerator = factory.create_markov_chain_text_generator()
+ assert(isinstance(testGenerator, TextGenerator))
+
+ def test_create_LTSM_text_generator(self):
+ # factory = self.textGeneratorFactory
+ # testGenerator = factory.create_LTSM_text_generator()
+ # assert(isinstance(testGenerator, TextGenerator))
+ pass
| Create Generator class and set up dependency injection
Create a core `Generator` class per our design and set up dependency injection to inject `Model`s (of course, these names can be changed if necessary). Writing some tests (e.g. with pytest) would also be nice. | 0.0 | 2b432039b993c7466903ac2e0e1c4d1ca4ab062a | [
"mimic/tests/test_text_generator_factory.py::TestTextGeneratorFactory::test_create_LTSM_text_generator"
]
| []
| {
"failed_lite_validators": [
"has_added_files"
],
"has_test_patch": true,
"is_lite": false
} | 2019-02-16 16:07:26+00:00 | mit | 6,148 |
|
ubclaunchpad__rocket2-168 | diff --git a/db/dynamodb.py b/db/dynamodb.py
index 3ddf148..32b9835 100644
--- a/db/dynamodb.py
+++ b/db/dynamodb.py
@@ -111,7 +111,7 @@ class DynamoDB:
**Note**: This function should **not** be called externally, and should
only be called on initialization.
- Teams are only required to have a ``github_team_name``. Since this is a
+ Teams are only required to have a ``github_team_id``. Since this is a
NoSQL database, no other attributes are required.
"""
logging.info("Creating table '{}'".format(self.teams_table))
@@ -119,13 +119,13 @@ class DynamoDB:
TableName=self.teams_table,
AttributeDefinitions=[
{
- 'AttributeName': 'github_team_name',
+ 'AttributeName': 'github_team_id',
'AttributeType': 'S'
},
],
KeySchema=[
{
- 'AttributeName': 'github_team_name',
+ 'AttributeName': 'github_team_id',
'KeyType': 'HASH'
},
],
@@ -167,7 +167,7 @@ class DynamoDB:
place_if_filled('email', user.get_email())
place_if_filled('name', user.get_name())
place_if_filled('github', user.get_github_username())
- place_if_filled('guid', user.get_github_id())
+ place_if_filled('github_user_id', user.get_github_id())
place_if_filled('major', user.get_major())
place_if_filled('position', user.get_position())
place_if_filled('bio', user.get_biography())
@@ -195,6 +195,7 @@ class DynamoDB:
teams_table = self.ddb.Table(self.teams_table)
tdict = {
+ 'github_team_id': team.get_github_team_id(),
'github_team_name': team.get_github_team_name()
}
place_if_filled('display_name', team.get_display_name())
@@ -238,7 +239,7 @@ class DynamoDB:
user.set_email(d.get('email', ''))
user.set_name(d.get('name', ''))
user.set_github_username(d.get('github', ''))
- user.set_github_id(d.get('guid', ''))
+ user.set_github_id(d.get('github_user_id', ''))
user.set_major(d.get('major', ''))
user.set_position(d.get('position', ''))
user.set_biography(d.get('bio', ''))
@@ -247,7 +248,7 @@ class DynamoDB:
'members')])
return user
- def retrieve_team(self, team_name):
+ def retrieve_team(self, team_id):
"""
Retrieve team from teams table.
@@ -259,13 +260,14 @@ class DynamoDB:
response = team_table.get_item(
TableName=self.teams_table,
Key={
- 'github_team_name': team_name
+ 'github_team_id': team_id
}
)
+
if 'Item' in response.keys():
return self.team_from_dict(response['Item'])
else:
- raise LookupError('Team "{}" not found'.format(team_name))
+ raise LookupError('Team "{}" not found'.format(team_id))
@staticmethod
def team_from_dict(d):
@@ -274,7 +276,9 @@ class DynamoDB:
:return: returns converted team model.
"""
- team = Team(d['github_team_name'], d.get('display_name', ''))
+ team = Team(d['github_team_id'],
+ d['github_team_name'],
+ d.get('display_name', ''))
team.set_platform(d.get('platform', ''))
members = set(d.get('members', []))
for member in members:
@@ -370,17 +374,19 @@ class DynamoDB:
}
)
- def delete_team(self, team_name):
+ def delete_team(self, team_id):
"""
Remove a team from the teams table.
- :param team_name: the team_name of the team to be removed
+ To obtain the team github id, you have to retrieve the team first.
+
+ :param team_id: the team_id of the team to be removed
"""
logging.info("Deleting team {} from table {}".
- format(team_name, self.teams_table))
+ format(team_id, self.teams_table))
team_table = self.ddb.Table(self.teams_table)
team_table.delete_item(
Key={
- 'github_team_name': team_name
+ 'github_team_id': team_id
}
)
diff --git a/docs/Database.md b/docs/Database.md
index 24e4238..353b107 100644
--- a/docs/Database.md
+++ b/docs/Database.md
@@ -12,6 +12,7 @@ Attribute Name | Description
`slack_id` | `String`; The user's slack id
`email` | `String`; The user's email address
`github` | `String`; The user's Github handler
+`github_user_id` | `String`; The user's Github user ID
`major` | `String`; The subject major the user is in
`position` | `String`; The user's position in _Launch Pad_
`bio` | `String`; A short (auto)biography (about the user)
@@ -28,7 +29,8 @@ and are also listed here:
Attribute Name | Description
---|---
-`github_team_name` | `String`; The team's github name
+`github_team_id` | `String`; The team's Github ID
+`github_team_name` | `String`; The team's Github name
`display_name` | `String`; The teams's display
`platform` | `String`; The team's working platform
-`members` | `String Set`; The team's set of members
+`members` | `String Set`; The team's set of members' Github IDs
diff --git a/model/team.py b/model/team.py
index 302d409..7e1d3af 100644
--- a/model/team.py
+++ b/model/team.py
@@ -4,11 +4,13 @@
class Team:
"""Represent a team with related fields and methods."""
- def __init__(self, github_team_name, display_name):
- """Initialize the team.
+ def __init__(self, github_team_id, github_team_name, display_name):
+ """
+ Initialize the team.
- Parameters are a valid Github team name and display name.
+ Parameters are a valid Github team ID, team name and display name.
"""
+ self.__github_team_id = github_team_id
self.__github_team_name = github_team_name
self.__display_name = display_name
self.__platform = ""
@@ -21,11 +23,13 @@ class Team:
Required fields for database to accept:
- ``__github_team_name``
+ - ``__github_team_id``
:param team: team to check
:return: returns true if this team has no missing required fields
"""
- return len(team.get_github_team_name()) > 0
+ return len(team.get_github_team_name()) > 0 and\
+ len(team.get_github_team_id()) > 0
def __eq__(self, other):
"""Return true if this team has the same attributes as the other."""
@@ -35,6 +39,14 @@ class Team:
"""Return the opposite of what is returned in self.__eq__(other)."""
return not (self == other)
+ def get_github_team_id(self):
+ """Return this team's unique Github team ID."""
+ return self.__github_team_id
+
+ def set_github_team_id(self, github_team_id):
+ """Set this team's unique Github team ID."""
+ self.__github_team_id = github_team_id
+
def get_github_team_name(self):
"""Return this team's unique Github team name."""
return self.__github_team_name
@@ -55,21 +67,21 @@ class Team:
"""Return this team's working platform."""
return self.__platform
- def add_member(self, slack_id):
- """Add a new member's Slack ID to the team's set of members' IDs."""
- self.__members.add(slack_id)
+ def add_member(self, github_user_id):
+ """Add a new member's Github ID to the team's set of members' IDs."""
+ self.__members.add(github_user_id)
- def discard_member(self, slack_id):
- """Discard the member of the team with the Slack ID in the argument."""
- self.__members.discard(slack_id)
+ def discard_member(self, github_user_id):
+ """Discard the member of the team with Github ID in the argument."""
+ self.__members.discard(github_user_id)
def get_members(self):
- """Return the set of all members' Slack IDs."""
+ """Return the set of all members' Github IDs."""
return self.__members
- def is_member(self, slack_id):
+ def is_member(self, github_user_id):
"""Identify if any member has the ID specified in the argument."""
- return slack_id in self.__members
+ return github_user_id in self.__members
def __str__(self):
"""Print information on the team class."""
diff --git a/model/user.py b/model/user.py
index 2970597..d134dcc 100644
--- a/model/user.py
+++ b/model/user.py
@@ -99,9 +99,9 @@ class User:
"""Return this user's Github ID."""
return self.__github_id
- def set_github_id(self, guid):
+ def set_github_id(self, github_user_id):
"""Set this user's Github ID."""
- self.__github_id = guid
+ self.__github_id = github_user_id
def get_major(self):
"""Return this user's major."""
| ubclaunchpad/rocket2 | 03287856ef69569fcb9547c72a7f745d194f7bf5 | diff --git a/tests/db/dynamodb_test.py b/tests/db/dynamodb_test.py
index 030ae9b..2ddc61a 100644
--- a/tests/db/dynamodb_test.py
+++ b/tests/db/dynamodb_test.py
@@ -38,7 +38,7 @@ def test_store_invalid_user(ddb_connection):
def test_store_invalid_team(ddb_connection):
"""Test handling of invalid team."""
ddb = ddb_connection
- team = Team('', 'Brussel Sprouts')
+ team = Team('1', '', 'Brussel Sprouts')
success = ddb.store_team(team)
assert not success
@@ -108,11 +108,11 @@ def test_retrieve_invalid_team(ddb_connection):
"""Test to see if we can retrieve a non-existent team."""
ddb = ddb_connection
try:
- team = ddb.retrieve_team('rocket2.0')
+ team = ddb.retrieve_team('1')
assert False
except LookupError as e:
- assert str(e) == 'Team "{}" not found'.format('rocket2.0')
+ assert str(e) == 'Team "{}" not found'.format('1')
@pytest.mark.db
@@ -135,38 +135,38 @@ def test_update_user(ddb_connection):
def test_update_team(ddb_connection):
"""Test to see if we can update a team."""
ddb = ddb_connection
- t = Team('brussel-sprouts', 'Brussel Sprouts')
+ t = Team('1', 'brussel-sprouts', 'Brussel Sprouts')
ddb.store_team(t)
- t = ddb.retrieve_team('brussel-sprouts')
+ t = ddb.retrieve_team('1')
t.add_member('abc_123')
t.add_member('123_abc')
ddb.store_team(t)
- assert len(ddb.retrieve_team('brussel-sprouts').get_members()) == 2
+ assert len(ddb.retrieve_team('1').get_members()) == 2
- ddb.delete_team('brussel-sprouts')
+ ddb.delete_team('1')
@pytest.mark.db
def test_store_retrieve_team(ddb_connection):
"""Test to see if we can store and retrieve the same team."""
ddb = ddb_connection
- team = create_test_team('rocket2.0', 'Rocket 2.0')
+ team = create_test_team('1', 'rocket2.0', 'Rocket 2.0')
assert ddb.store_team(team)
- another_team = ddb.retrieve_team('rocket2.0')
+ another_team = ddb.retrieve_team('1')
assert team == another_team
- ddb.delete_team('rocket2.0')
+ ddb.delete_team('1')
@pytest.mark.db
def test_query_team(ddb_connection):
"""Test to see if we can store and query the same team."""
ddb = ddb_connection
- team = create_test_team('rocket2.0', 'Rocket 2.0')
- team2 = create_test_team('lame-o', 'Lame-O Team')
+ team = create_test_team('1', 'rocket2.0', 'Rocket 2.0')
+ team2 = create_test_team('2', 'lame-o', 'Lame-O Team')
team2.add_member('apple')
ddb.store_team(team)
ddb.store_team(team2)
@@ -185,8 +185,8 @@ def test_query_team(ddb_connection):
assert team == multiple_queries[0]
assert team2 == member_team[0]
- ddb.delete_team('rocket2.0')
- ddb.delete_team('lame-o')
+ ddb.delete_team('1')
+ ddb.delete_team('2')
@pytest.mark.db
@@ -205,9 +205,9 @@ def test_delete_user(ddb_connection):
def test_delete_team(ddb_connection):
"""Test to see if we can successfully delete a team."""
ddb = ddb_connection
- team = create_test_team('rocket-2.0', 'Rocket 2.0')
+ team = create_test_team('1', 'rocket-2.0', 'Rocket 2.0')
ddb.store_team(team)
assert len(ddb.query_team([])) == 1
- ddb.delete_team('rocket-2.0')
+ ddb.delete_team('1')
assert len(ddb.query_team([])) == 0
diff --git a/tests/db/facade_test.py b/tests/db/facade_test.py
index 0d225d2..9561052 100644
--- a/tests/db/facade_test.py
+++ b/tests/db/facade_test.py
@@ -40,7 +40,7 @@ def test_query_user(ddb):
def test_store_team(ddb):
"""Test storing team calls correct functions."""
dbf = DBFacade(ddb)
- test_team = create_test_team('brussel-sprouts', 'Brussel Sprouts')
+ test_team = create_test_team('1', 'brussel-sprouts', 'Brussel Sprouts')
dbf.store_team(test_team)
ddb.store_team.assert_called_with(test_team)
diff --git a/tests/model/team_test.py b/tests/model/team_test.py
index c5ad2bd..c02a1f1 100644
--- a/tests/model/team_test.py
+++ b/tests/model/team_test.py
@@ -5,62 +5,75 @@ from tests.util import create_test_team
def test_team_equality():
"""Test the Team class method __eq__() and __ne__()."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
- team2 = Team("brussel-sprouts", "Brussel Sprouts")
- team3 = Team("brussel-trouts", "Brussel Trouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
+ team2 = Team("1", "brussel-sprouts", "Brussel Sprouts")
+ team3 = Team("1", "brussel-trouts", "Brussel Trouts")
assert team == team2
assert team != team3
def test_valid_team():
"""Test the Team static class method is_valid()."""
- team = Team("", "Brussel Sprouts")
+ team = Team("1", "", "Brussel Sprouts")
assert not Team.is_valid(team)
- team = create_test_team("brussel-sprouts", "Brussel Sprouts")
+ team = create_test_team("1", "brussel-sprouts", "Brussel Sprouts")
assert Team.is_valid(team)
+def test_get_github_team_id():
+ """Test the Team class method get_github_team_id()."""
+ team = Team('1', 'brussel-sprouts', 'Brussel Sprouts')
+ assert team.get_github_team_id() == '1'
+
+
+def test_set_github_team_id():
+ """Test the Team class method set_github_team_id()."""
+ team = Team('1', 'brussel-sprouts', 'Brussel Sprouts')
+ team.set_github_team_id('2')
+ assert team.get_github_team_id() == '2'
+
+
def test_get_github_team_name():
"""Test the Team class method set_github_team_name()."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
assert team.get_github_team_name() == "brussel-sprouts"
def test_get_display_name():
"""Test the Team class method get_display_name()."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
assert team.get_display_name() == "Brussel Sprouts"
def test_set_display_name():
"""Test the Team class method set_display_name(display_name)."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
team.set_display_name("Corn Cobs")
assert team.get_display_name() == "Corn Cobs"
def test_get_platform():
"""Test the Team class method get_platform()."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
assert team.get_platform() == ""
def test_set_platform():
"""Test the Team class method set_platform(platform)."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
team.set_platform("web")
assert team.get_platform() == "web"
def test_get_members():
"""Test the Team class method get_members()."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
assert team.get_members() == set()
def test_add_member():
"""Test the Team class method add_member(uuid)."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
new_slack_id = "U0G9QF9C6"
team.add_member(new_slack_id)
assert new_slack_id in team.get_members()
@@ -68,7 +81,7 @@ def test_add_member():
def test_discard_member():
"""Test the Team class method discard_member(slack_id)."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
new_slack_id = "U0G9QF9C6"
team.add_member(new_slack_id)
team.discard_member(new_slack_id)
@@ -77,7 +90,7 @@ def test_discard_member():
def test_is_member():
"""Test the Team class method is_member(slack_id)."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
new_slack_id = "U0G9QF9C6"
assert team.is_member(new_slack_id) is False
team.add_member(new_slack_id)
@@ -86,11 +99,12 @@ def test_is_member():
def test_print():
"""Test print team class."""
- team = Team("brussel-sprouts", "Brussel Sprouts")
+ team = Team("1", "brussel-sprouts", "Brussel Sprouts")
new_slack_id = "U0G9QF9C6"
team.add_member(new_slack_id)
team.set_platform("web")
- assert str(team) == "{'_Team__github_team_name': 'brussel-sprouts'," \
+ assert str(team) == "{'_Team__github_team_id': '1'," \
+ " '_Team__github_team_name': 'brussel-sprouts'," \
" '_Team__display_name': 'Brussel Sprouts'," \
" '_Team__platform': 'web'," \
" '_Team__members': {'U0G9QF9C6'}}"
diff --git a/tests/util.py b/tests/util.py
index 37bb6b7..bea3875 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -23,14 +23,14 @@ def create_test_user(slack_id):
return u
-def create_test_team(team_name, display_name):
+def create_test_team(tid, team_name, display_name):
"""
Create a test team with team name, and with all other attributes the same.
:param team_name: The github team name string
:return: returns a filled-in user model (no empty strings)
"""
- t = Team(team_name, display_name)
+ t = Team(tid, team_name, display_name)
t.set_platform('slack')
t.add_member('abc_123')
return t
| Switch slack IDs in team table to Github ID
Currently the users and teams tables are strongly coupled, as the team table uses the slack IDs that are the primary keys of the users table. However, since we will assume Github is the source of truth for teams, we should instead store Github IDs. | 0.0 | 03287856ef69569fcb9547c72a7f745d194f7bf5 | [
"tests/model/team_test.py::test_team_equality",
"tests/model/team_test.py::test_valid_team",
"tests/model/team_test.py::test_get_github_team_id",
"tests/model/team_test.py::test_set_github_team_id",
"tests/model/team_test.py::test_get_github_team_name",
"tests/model/team_test.py::test_get_display_name",
"tests/model/team_test.py::test_set_display_name",
"tests/model/team_test.py::test_get_platform",
"tests/model/team_test.py::test_set_platform",
"tests/model/team_test.py::test_get_members",
"tests/model/team_test.py::test_add_member",
"tests/model/team_test.py::test_discard_member",
"tests/model/team_test.py::test_is_member",
"tests/model/team_test.py::test_print"
]
| []
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2019-01-16 22:30:56+00:00 | mit | 6,149 |
|
ubclaunchpad__rocket2-219 | diff --git a/command/commands/user.py b/command/commands/user.py
index 84a5307..75f8ef4 100644
--- a/command/commands/user.py
+++ b/command/commands/user.py
@@ -229,7 +229,7 @@ class UserCommand:
:param user_id: Slack ID of user to be added
:param use_force: If this is set, we store the user even if they are
- already added in the database
+ already added in the database
:return: ``"User added!", 200``
"""
# Try to look up and avoid overwriting if we are not using force
diff --git a/command/core.py b/command/core.py
index 57d7700..a9c4174 100644
--- a/command/core.py
+++ b/command/core.py
@@ -1,5 +1,6 @@
"""Calls the appropriate handler depending on the event data."""
from command.commands.user import UserCommand
+import command.util as util
from model.user import User
from interface.slack import SlackAPIError
import logging
@@ -18,17 +19,19 @@ class Core:
self.__commands["user"] = UserCommand(self.__facade, self.__github)
def handle_app_command(self, cmd_txt, user):
- """Handle a command call to rocket."""
- def regularize_char(c):
- if c == "‘" or c == "’":
- return "'"
- if c == '“' or c == '”':
- return '"'
- return c
+ """
+ Handle a command call to rocket.
+ :param cmd_txt: the command itself
+ :param user: slack ID of user who executed the command
+ :return: tuple where first element is the response text (or a
+ ``flask.Response`` object), and the second element
+ is the response status code
+ """
# Slightly hacky way to deal with Apple platform
# smart punctuation messing with argparse.
- cmd_txt = ''.join(map(regularize_char, cmd_txt))
+ cmd_txt = ''.join(map(util.regularize_char, cmd_txt))
+ cmd_txt = util.escaped_id_to_id(cmd_txt)
s = cmd_txt.split(' ', 1)
if s[0] == "help" or s[0] is None:
logging.info("Help command was called")
@@ -40,7 +43,11 @@ class Core:
return 'Please enter a valid command', 200
def handle_team_join(self, event_data):
- """Handle the event of a new user joining the workspace."""
+ """
+ Handle the event of a new user joining the workspace.
+
+ :param event_data: JSON event data
+ """
new_id = event_data["event"]["user"]["id"]
new_user = User(new_id)
self.__facade.store_user(new_user)
@@ -52,7 +59,12 @@ class Core:
logging.error(new_id + " added to database - user not notified")
def get_help(self):
- """Get help messages and return a formatted string for messaging."""
+ """
+ Get help messages and return a formatted string for messaging.
+
+ :return: Preformatted ``flask.Response`` object containing help
+ messages
+ """
message = {"text": "Displaying all available commands. "
"To read about a specific command, use "
"\n`/rocket [command] help`\n",
diff --git a/command/util.py b/command/util.py
new file mode 100644
index 0000000..0e13756
--- /dev/null
+++ b/command/util.py
@@ -0,0 +1,42 @@
+"""
+Some utility functions.
+
+The following are a few function to help in command handling.
+"""
+import re
+
+
+def regularize_char(c):
+ """
+ Convert any unicode quotation marks to ascii ones.
+
+ Leaves all other characters alone.
+
+ :param c: character to convert
+ :return: ascii equivalent (only quotes are changed)
+ """
+ if c == "‘" or c == "’":
+ return "'"
+ if c == '“' or c == '”':
+ return '"'
+ return c
+
+
+def escaped_id_to_id(s):
+ """
+ Convert an string with escaped IDs to just the IDs.
+
+ Before::
+
+ /rocket user edit --member <@U1143214|su> --name "Steven Universe"
+
+ After::
+
+ /rocket user edit --member U1143214 --name "Steven Universe"
+
+ :param s: string to convert
+ :return: string where all instances of escaped ID is replaced with IDs
+ """
+ return re.sub(r"<@(\w+)\|[^>]+>",
+ r"\1",
+ s)
diff --git a/conf.py b/conf.py
index 51b8c1d..a10bce7 100644
--- a/conf.py
+++ b/conf.py
@@ -62,7 +62,7 @@ language = None
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'README.md',
- '.github/PULL_REQUEST_TEMPLATE.md', '*/README.md']
+ '.github/*', '*/README.md']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'emacs'
diff --git a/docs/api/command.rst b/docs/api/command.rst
index a620f2d..79d1b4c 100644
--- a/docs/api/command.rst
+++ b/docs/api/command.rst
@@ -5,8 +5,10 @@ Commands Core
-------------
.. automodule:: command.core
- :members:
+ :members:
+.. automodule:: command.util
+ :members:
User
----
| ubclaunchpad/rocket2 | a2e78fff94073c458a68262fafce1d1fa1daa62b | diff --git a/tests/command/util_test.py b/tests/command/util_test.py
new file mode 100644
index 0000000..38d0b46
--- /dev/null
+++ b/tests/command/util_test.py
@@ -0,0 +1,31 @@
+"""Some tests for utility functions in commands utility."""
+import command.util as util
+
+
+def test_regularize_char_standard():
+ """Test how this function reacts to normal operation."""
+ assert util.regularize_char('a') == 'a'
+ assert util.regularize_char(' ') == ' '
+ assert util.regularize_char('\'') == '\''
+ assert util.regularize_char('‘') == '\''
+ assert util.regularize_char('’') == '\''
+ assert util.regularize_char('“') == '"'
+ assert util.regularize_char('”') == '"'
+
+
+def test_escaped_id_conversion():
+ """Test how this function reacts to normal operation."""
+ CMDS = [
+ # Normal operation
+ ('/rocket user edit --member <@U1234|user> --name "User"',
+ '/rocket user edit --member U1234 --name "User"'),
+ # No users
+ ('/rocket user view',
+ '/rocket user view'),
+ # Multiple users
+ ('/rocket foo <@U1234|user> <@U4321|ruse> <@U3412|sure> -h',
+ '/rocket foo U1234 U4321 U3412 -h')
+ ]
+
+ for inp, expect in CMDS:
+ assert util.escaped_id_to_id(inp) == expect
| Slash commands convert user handles to user IDs?
While RTM uses user slack IDs, slash commands don't. Please find a way to resolve this. There are 2 preferred ways:
1. There is an option for slash commands to automagically convert handles to IDs
2. We just use handles in place of IDs, except for RTMs, where we convert the IDs to handles | 0.0 | a2e78fff94073c458a68262fafce1d1fa1daa62b | [
"tests/command/util_test.py::test_regularize_char_standard",
"tests/command/util_test.py::test_escaped_id_conversion"
]
| []
| {
"failed_lite_validators": [
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2019-02-12 21:08:18+00:00 | mit | 6,150 |
|
ubermag__discretisedfield-334 | diff --git a/discretisedfield/plotting/mpl_field.py b/discretisedfield/plotting/mpl_field.py
index a8724ddd..2a51e24c 100644
--- a/discretisedfield/plotting/mpl_field.py
+++ b/discretisedfield/plotting/mpl_field.py
@@ -37,7 +37,7 @@ class MplField(Mpl):
def __init__(self, field):
if field.mesh.region.ndim != 2:
- raise ValueError(
+ raise RuntimeError(
"Only fields on 2d meshes can be plotted with matplotlib, not"
f" {field.mesh.region.ndim=}."
)
| ubermag/discretisedfield | 19087f9def7574f2cbf87fb53baf943be8948c57 | diff --git a/discretisedfield/tests/test_field.py b/discretisedfield/tests/test_field.py
index fc82c893..49144f9a 100644
--- a/discretisedfield/tests/test_field.py
+++ b/discretisedfield/tests/test_field.py
@@ -2739,7 +2739,7 @@ def test_mpl_scalar(test_field):
test_field.a.sel("x").mpl.scalar(filename=tmpfilename)
# Exceptions
- with pytest.raises(ValueError):
+ with pytest.raises(RuntimeError):
test_field.a.mpl.scalar() # not sliced
with pytest.raises(ValueError):
test_field.sel("z").mpl.scalar() # vector field
@@ -2773,7 +2773,7 @@ def test_mpl_lightess(test_field):
field.sel("z").mpl.lightness(filename=tmpfilename)
# Exceptions
- with pytest.raises(ValueError):
+ with pytest.raises(RuntimeError):
test_field.mpl.lightness() # not sliced
with pytest.raises(ValueError):
# wrong filter field
@@ -2829,7 +2829,7 @@ def test_mpl_vector(test_field):
test_field.sel("x").mpl.vector(filename=tmpfilename)
# Exceptions
- with pytest.raises(ValueError):
+ with pytest.raises(RuntimeError):
test_field.mpl.vector() # not sliced
with pytest.raises(ValueError):
test_field.b.sel("z").mpl.vector() # scalar field
@@ -2864,7 +2864,7 @@ def test_mpl_contour(test_field):
test_field.sel("z").c.mpl.contour(filename=tmpfilename)
# Exceptions
- with pytest.raises(ValueError):
+ with pytest.raises(RuntimeError):
test_field.mpl.contour() # not sliced
with pytest.raises(ValueError):
test_field.sel("z").mpl.contour() # vector field
@@ -2909,12 +2909,24 @@ def test_mpl(test_field):
test_field.sel("x").mpl(filename=tmpfilename)
# Exception
- with pytest.raises(ValueError):
+ with pytest.raises(RuntimeError):
test_field.mpl()
plt.close("all")
+def test_mpl_dimension(valid_mesh):
+ field = df.Field(valid_mesh, nvdim=1)
+
+ if valid_mesh.region.ndim != 2:
+ with pytest.raises(RuntimeError):
+ field.mpl.scalar()
+ else:
+ field.mpl.scalar()
+
+ plt.close("all")
+
+
def test_hv_scalar(test_field):
for kdims in [["x", "y"], ["x", "z"], ["y", "z"]]:
normal = (set("xyz") - set(kdims)).pop()
diff --git a/discretisedfield/tests/test_mesh.py b/discretisedfield/tests/test_mesh.py
index 5a2fe72d..3f08ba2d 100644
--- a/discretisedfield/tests/test_mesh.py
+++ b/discretisedfield/tests/test_mesh.py
@@ -1287,12 +1287,13 @@ def test_dV(p1, p2, cell, dV):
def test_mpl(valid_mesh, tmp_path):
if valid_mesh.region.ndim != 3:
- pytest.xfail(reason="plotting only supports 3d")
-
- valid_mesh.mpl()
- valid_mesh.mpl(box_aspect=[1, 2, 3])
+ with pytest.raises(RuntimeError):
+ valid_mesh.mpl()
+ else:
+ valid_mesh.mpl()
+ valid_mesh.mpl(box_aspect=[1, 2, 3])
+ valid_mesh.mpl(filename=tmp_path / "figure.pdf")
- valid_mesh.mpl(filename=tmp_path / "figure.pdf")
plt.close("all")
@@ -1533,17 +1534,16 @@ def test_save_load_subregions(p1, p2, cell, tmp_path):
assert test_mesh.subregions == sr
[email protected](reason="needs nd field")
-def test_coordinate_field(valid_mesh): # TODO
+def test_coordinate_field(valid_mesh):
cfield = valid_mesh.coordinate_field()
assert isinstance(cfield, df.Field)
- manually = df.Field(valid_mesh, dim=valid_mesh.region.ndim, value=lambda p: p)
+ manually = df.Field(valid_mesh, nvdim=valid_mesh.region.ndim, value=lambda p: p)
assert cfield.allclose(manually, atol=0)
- for dim in range(valid_mesh.region.ndim):
- index = [
- 0,
- ] * valid_mesh.region.ndim
+ for dim in valid_mesh.region.dims:
+ index = [0] * valid_mesh.region.ndim
index[valid_mesh.region._dim2index(dim)] = slice(None)
+ # extra index for vector dimension: vector component along the current direction
+ index = tuple(index) + (valid_mesh.region._dim2index(dim),)
assert np.allclose(cfield.array[index], getattr(valid_mesh.points, dim), atol=0)
diff --git a/discretisedfield/tests/test_region.py b/discretisedfield/tests/test_region.py
index 724c5eed..ac0c3edf 100644
--- a/discretisedfield/tests/test_region.py
+++ b/discretisedfield/tests/test_region.py
@@ -771,20 +771,20 @@ def test_mpl(p1, p2, tmp_path):
region = df.Region(p1=p1, p2=p2)
if region.ndim != 3:
- pytest.xfail(reason="plotting only supports 3d")
-
- # Check if it runs.
- region.mpl()
- region.mpl(
- figsize=(10, 10),
- multiplier=1e-9,
- color=plot_util.cp_hex[1],
- linewidth=3,
- box_aspect=(1, 1.5, 2),
- linestyle="dashed",
- )
-
- region.mpl(filename=tmp_path / "figure.pdf")
+ with pytest.raises(RuntimeError):
+ region.mpl()
+ else:
+ # Check if it runs.
+ region.mpl()
+ region.mpl(
+ figsize=(10, 10),
+ multiplier=1e-9,
+ color=plot_util.cp_hex[1],
+ linewidth=3,
+ box_aspect=(1, 1.5, 2),
+ linestyle="dashed",
+ )
+ region.mpl(filename=tmp_path / "figure.pdf")
plt.close("all")
| Plotting exceptions
The exceptions for wrong mesh dimensionality when trying to create a plot are not consistent between mpl, k3d. and hv. | 0.0 | 19087f9def7574f2cbf87fb53baf943be8948c57 | [
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-0.34145574821561386-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-0.34145574821561386-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-0.34145574821561386-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-0.34145574821561386-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-0.34145574821561386-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-0.34145574821561386-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-0.34145574821561386-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-0.34145574821561386-None]",
"discretisedfield/tests/test_field.py::test_mpl_dimension[valid_mesh0]",
"discretisedfield/tests/test_field.py::test_mpl_dimension[valid_mesh2]",
"discretisedfield/tests/test_field.py::test_mpl_dimension[valid_mesh3]",
"discretisedfield/tests/test_field.py::test_mpl_dimension[valid_mesh4]",
"discretisedfield/tests/test_field.py::test_mpl_dimension[valid_mesh5]",
"discretisedfield/tests/test_field.py::test_mpl_dimension[valid_mesh6]",
"discretisedfield/tests/test_field.py::test_mpl_dimension[valid_mesh7]"
]
| [
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0--5.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-3.141592653589793-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-1e-15-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-1200000000000.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-(1+1j)-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh0-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1--5.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-3.141592653589793-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-1e-15-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-1200000000000.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-(1+1j)-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh1-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2--5.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-3.141592653589793-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-1e-15-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-1200000000000.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-(1+1j)-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh2-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3--5.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-3.141592653589793-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-1e-15-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-1200000000000.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-(1+1j)-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh3-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4--5.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-3.141592653589793-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-1e-15-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-1200000000000.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-(1+1j)-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh4-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5--5.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-3.141592653589793-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-1e-15-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-1200000000000.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-(1+1j)-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh5-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6--5.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-3.141592653589793-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-1e-15-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-1200000000000.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-(1+1j)-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh6-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7--5.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-3.141592653589793-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-1e-15-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-1200000000000.0-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-(1+1j)-None]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_init_scalar_valid_args[valid_mesh7-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value0-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value1-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value2-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value3-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value4-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value5-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value6-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value7-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-value8-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh0-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value0-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value1-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value2-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value3-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value4-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value5-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value6-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value7-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-value8-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh1-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value0-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value1-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value2-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value3-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value4-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value5-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value6-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value7-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-value8-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh2-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value0-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value1-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value2-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value3-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value4-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value5-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value6-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value7-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-value8-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh3-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value0-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value1-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value2-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value3-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value4-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value5-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value6-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value7-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-value8-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh4-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value0-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value1-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value2-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value3-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value4-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value5-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value6-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value7-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-value8-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh5-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value0-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value1-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value2-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value3-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value4-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value5-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value6-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value7-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-value8-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh6-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value0-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value1-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value2-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value3-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value4-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value5-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value6-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value7-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-value8-None]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_init_vector_valid_args[valid_mesh7-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh0-1-<lambda>-complex128-None]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh0-1-<lambda>-complex128-T]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh0-1-<lambda>-complex128-A/m]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh1-4-<lambda>-float64-None]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh1-4-<lambda>-float64-T]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh1-4-<lambda>-float64-A/m]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh2-2-<lambda>-float64-None]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh2-2-<lambda>-float64-T]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh2-2-<lambda>-float64-A/m]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh3-3-<lambda>-float64-None]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh3-3-<lambda>-float64-T]",
"discretisedfield/tests/test_field.py::test_init_special_combinations[mesh3-3-<lambda>-float64-A/m]",
"discretisedfield/tests/test_field.py::test_init_invalid_arguments",
"discretisedfield/tests/test_field.py::test_init_invalid_nvdims[0-ValueError]",
"discretisedfield/tests/test_field.py::test_init_invalid_nvdims[-1-ValueError]",
"discretisedfield/tests/test_field.py::test_init_invalid_nvdims[dim-TypeError]",
"discretisedfield/tests/test_field.py::test_init_invalid_nvdims[nvdim3-TypeError]",
"discretisedfield/tests/test_field.py::test_set_with_ndarray[valid_mesh0]",
"discretisedfield/tests/test_field.py::test_set_with_ndarray[valid_mesh1]",
"discretisedfield/tests/test_field.py::test_set_with_ndarray[valid_mesh2]",
"discretisedfield/tests/test_field.py::test_set_with_ndarray[valid_mesh3]",
"discretisedfield/tests/test_field.py::test_set_with_ndarray[valid_mesh4]",
"discretisedfield/tests/test_field.py::test_set_with_ndarray[valid_mesh5]",
"discretisedfield/tests/test_field.py::test_set_with_ndarray[valid_mesh6]",
"discretisedfield/tests/test_field.py::test_set_with_ndarray[valid_mesh7]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh0-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh0-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh0-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh0-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh0-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh1-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh1-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh1-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh1-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh1-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh2-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh2-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh2-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh2-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh2-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh3-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh3-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh3-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh3-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh3-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh4-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh4-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh4-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh4-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh4-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh5-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh5-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh5-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh5-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh5-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh6-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh6-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh6-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh6-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh6-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh7-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh7-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh7-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh7-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_set_with_callable_scalar[valid_mesh7-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh0-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh0-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh0-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh0-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh0-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh1-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh1-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh1-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh1-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh1-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh2-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh2-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh2-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh2-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh2-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh3-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh3-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh3-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh3-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh3-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh4-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh4-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh4-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh4-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh4-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh5-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh5-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh5-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh5-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh5-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh6-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh6-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh6-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh6-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh6-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh7-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh7-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh7-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh7-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_set_with_callable_vector[valid_mesh7-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_set_with_dict",
"discretisedfield/tests/test_field.py::test_set_exception[valid_mesh0]",
"discretisedfield/tests/test_field.py::test_set_exception[valid_mesh1]",
"discretisedfield/tests/test_field.py::test_set_exception[valid_mesh2]",
"discretisedfield/tests/test_field.py::test_set_exception[valid_mesh3]",
"discretisedfield/tests/test_field.py::test_set_exception[valid_mesh4]",
"discretisedfield/tests/test_field.py::test_set_exception[valid_mesh5]",
"discretisedfield/tests/test_field.py::test_set_exception[valid_mesh6]",
"discretisedfield/tests/test_field.py::test_set_exception[valid_mesh7]",
"discretisedfield/tests/test_field.py::test_vdims[valid_mesh2]",
"discretisedfield/tests/test_field.py::test_vdims[valid_mesh6]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh0-1]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh0-2]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh0-3]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh0-4]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh1-1]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh1-2]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh1-3]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh1-4]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh2-1]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh2-2]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh2-3]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh2-4]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh3-1]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh3-2]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh3-3]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh3-4]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh4-1]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh4-2]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh4-3]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh4-4]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh5-1]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh5-2]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh5-3]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh5-4]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh6-1]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh6-2]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh6-3]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh6-4]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh7-1]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh7-2]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh7-3]",
"discretisedfield/tests/test_field.py::test_valid_single_value[valid_mesh7-4]",
"discretisedfield/tests/test_field.py::test_valid_set_call[1-1]",
"discretisedfield/tests/test_field.py::test_valid_set_call[1-2]",
"discretisedfield/tests/test_field.py::test_valid_set_call[1-3]",
"discretisedfield/tests/test_field.py::test_valid_set_call[1-4]",
"discretisedfield/tests/test_field.py::test_valid_set_call[2-1]",
"discretisedfield/tests/test_field.py::test_valid_set_call[2-2]",
"discretisedfield/tests/test_field.py::test_valid_set_call[2-3]",
"discretisedfield/tests/test_field.py::test_valid_set_call[2-4]",
"discretisedfield/tests/test_field.py::test_valid_set_call[3-1]",
"discretisedfield/tests/test_field.py::test_valid_set_call[3-2]",
"discretisedfield/tests/test_field.py::test_valid_set_call[3-3]",
"discretisedfield/tests/test_field.py::test_valid_set_call[3-4]",
"discretisedfield/tests/test_field.py::test_valid_set_call[4-1]",
"discretisedfield/tests/test_field.py::test_valid_set_call[4-2]",
"discretisedfield/tests/test_field.py::test_valid_set_call[4-3]",
"discretisedfield/tests/test_field.py::test_valid_set_call[4-4]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh0-1]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh0-2]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh0-3]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh0-4]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh1-1]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh1-2]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh1-3]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh1-4]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh2-1]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh2-2]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh2-3]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh2-4]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh3-1]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh3-2]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh3-3]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh3-4]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh4-1]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh4-2]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh4-3]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh4-4]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh5-1]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh5-2]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh5-3]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh5-4]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh6-1]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh6-2]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh6-3]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh6-4]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh7-1]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh7-2]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh7-3]",
"discretisedfield/tests/test_field.py::test_value[valid_mesh7-4]",
"discretisedfield/tests/test_field.py::test_average",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-1-1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-1-2.1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-1-0.001]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-2-1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-2-2.1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-2-0.001]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-3-1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-3-2.1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-3-0.001]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-4-1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-4-2.1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh2-4-0.001]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-1-1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-1-2.1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-1-0.001]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-2-1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-2-2.1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-2-0.001]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-3-1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-3-2.1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-3-0.001]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-4-1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-4-2.1]",
"discretisedfield/tests/test_field.py::test_norm[valid_mesh6-4-0.001]",
"discretisedfield/tests/test_field.py::test_vdim_mapping[0-1-5-1-None-vdim_mapping_check0]",
"discretisedfield/tests/test_field.py::test_vdim_mapping[p11-p21-n1-1-None-vdim_mapping_check1]",
"discretisedfield/tests/test_field.py::test_vdim_mapping[p12-p22-n2-2-None-vdim_mapping_check2]",
"discretisedfield/tests/test_field.py::test_vdim_mapping[p13-p23-n3-3-None-vdim_mapping_check3]",
"discretisedfield/tests/test_field.py::test_vdim_mapping[p14-p24-n4-4-None-vdim_mapping_check4]",
"discretisedfield/tests/test_field.py::test_vdim_mapping[0-1-5-2-vdim_mapping5-vdim_mapping_check5]",
"discretisedfield/tests/test_field.py::test_vdim_mapping[p16-p26-n6-3-vdim_mapping6-vdim_mapping_check6]",
"discretisedfield/tests/test_field.py::test_r_dim_mapping",
"discretisedfield/tests/test_field.py::test_vdim_mapping_error[2-vdim_mapping0-ValueError]",
"discretisedfield/tests/test_field.py::test_vdim_mapping_error[2-vdim_mapping1-ValueError]",
"discretisedfield/tests/test_field.py::test_vdim_mapping_error[2-vdim_mapping2-TypeError]",
"discretisedfield/tests/test_field.py::test_vdims_vdim_mapping",
"discretisedfield/tests/test_field.py::test_orientation[valid_mesh2-1]",
"discretisedfield/tests/test_field.py::test_orientation[valid_mesh2-2]",
"discretisedfield/tests/test_field.py::test_orientation[valid_mesh2-3]",
"discretisedfield/tests/test_field.py::test_orientation[valid_mesh2-4]",
"discretisedfield/tests/test_field.py::test_orientation[valid_mesh6-1]",
"discretisedfield/tests/test_field.py::test_orientation[valid_mesh6-2]",
"discretisedfield/tests/test_field.py::test_orientation[valid_mesh6-3]",
"discretisedfield/tests/test_field.py::test_orientation[valid_mesh6-4]",
"discretisedfield/tests/test_field.py::test_call",
"discretisedfield/tests/test_field.py::test_mean",
"discretisedfield/tests/test_field.py::test_field_component[valid_mesh2]",
"discretisedfield/tests/test_field.py::test_field_component[valid_mesh6]",
"discretisedfield/tests/test_field.py::test_get_attribute_exception",
"discretisedfield/tests/test_field.py::test_dir[valid_mesh0]",
"discretisedfield/tests/test_field.py::test_dir[valid_mesh1]",
"discretisedfield/tests/test_field.py::test_dir[valid_mesh2]",
"discretisedfield/tests/test_field.py::test_dir[valid_mesh3]",
"discretisedfield/tests/test_field.py::test_dir[valid_mesh4]",
"discretisedfield/tests/test_field.py::test_dir[valid_mesh5]",
"discretisedfield/tests/test_field.py::test_dir[valid_mesh6]",
"discretisedfield/tests/test_field.py::test_dir[valid_mesh7]",
"discretisedfield/tests/test_field.py::test_eq",
"discretisedfield/tests/test_field.py::test_allclose",
"discretisedfield/tests/test_field.py::test_integrate_volume",
"discretisedfield/tests/test_field.py::test_integrate_directional",
"discretisedfield/tests/test_field.py::test_integrate_exceptions",
"discretisedfield/tests/test_field.py::test_abs[valid_mesh2]",
"discretisedfield/tests/test_field.py::test_abs[valid_mesh6]",
"discretisedfield/tests/test_field.py::test_line",
"discretisedfield/tests/test_field.py::test_sel[mesh1-3-value1-0]",
"discretisedfield/tests/test_field.py::test_angle[valid_mesh2-1]",
"discretisedfield/tests/test_field.py::test_angle[valid_mesh2-2]",
"discretisedfield/tests/test_field.py::test_angle[valid_mesh2-3]",
"discretisedfield/tests/test_field.py::test_angle[valid_mesh2-4]",
"discretisedfield/tests/test_field.py::test_angle[valid_mesh6-1]",
"discretisedfield/tests/test_field.py::test_angle[valid_mesh6-2]",
"discretisedfield/tests/test_field.py::test_angle[valid_mesh6-3]",
"discretisedfield/tests/test_field.py::test_angle[valid_mesh6-4]",
"discretisedfield/tests/test_field.py::test_write_read_hdf5[testfile.hdf5-subregions0-1--1.23]",
"discretisedfield/tests/test_field.py::test_write_read_hdf5[testfile.hdf5-subregions0-3-value1]",
"discretisedfield/tests/test_field.py::test_write_read_hdf5[testfile.hdf5-subregions1-1--1.23]",
"discretisedfield/tests/test_field.py::test_write_read_hdf5[testfile.hdf5-subregions1-3-value1]",
"discretisedfield/tests/test_field.py::test_write_read_hdf5[testfile.h5-subregions0-1--1.23]",
"discretisedfield/tests/test_field.py::test_write_read_hdf5[testfile.h5-subregions0-3-value1]",
"discretisedfield/tests/test_field.py::test_write_read_hdf5[testfile.h5-subregions1-1--1.23]",
"discretisedfield/tests/test_field.py::test_write_read_hdf5[testfile.h5-subregions1-3-value1]",
"discretisedfield/tests/test_field.py::test_write_read_invalid_extension",
"discretisedfield/tests/test_field.py::test_mpl_dimension[valid_mesh1]",
"discretisedfield/tests/test_field.py::test_k3d[valid_mesh0]",
"discretisedfield/tests/test_field.py::test_k3d[valid_mesh1]",
"discretisedfield/tests/test_field.py::test_k3d[valid_mesh2]",
"discretisedfield/tests/test_field.py::test_k3d[valid_mesh6]",
"discretisedfield/tests/test_field.py::test_k3d[valid_mesh7]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh0-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh0-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh0-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh0-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh0-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh1-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh1-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh1-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh1-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh1-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh2-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh2-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh2-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh2-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh2-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh3-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh3-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh3-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh3-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh3-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh4-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh4-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh4-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh4-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh4-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh5-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh5-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh5-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh5-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh5-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh6-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh6-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh6-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh6-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh6-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh7-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh7-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh7-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh7-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_vector[valid_mesh7-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh0-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh0-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh0-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh0-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh0-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh1-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh1-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh1-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh1-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh1-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh2-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh2-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh2-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh2-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh2-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh3-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh3-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh3-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh3-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh3-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh4-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh4-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh4-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh4-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh4-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh5-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh5-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh5-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh5-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh5-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh6-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh6-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh6-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh6-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh6-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh7-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh7-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh7-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh7-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_to_xarray_valid_args_scalar[valid_mesh7-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh0-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh0-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh0-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh0-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh0-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh1-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh1-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh1-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh1-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh1-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh2-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh2-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh2-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh2-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh2-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh3-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh3-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh3-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh3-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh3-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh4-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh4-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh4-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh4-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh4-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh5-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh5-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh5-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh5-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh5-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh6-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh6-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh6-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh6-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh6-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh7-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh7-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh7-<lambda>-complex128_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh7-<lambda>-complex128_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_vector[valid_mesh7-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh0-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh0-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh0-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh0-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh0-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh1-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh1-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh1-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh1-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh1-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh2-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh2-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh2-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh2-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh2-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh3-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh3-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh3-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh3-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh3-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh4-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh4-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh4-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh4-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh4-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh5-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh5-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh5-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh5-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh5-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh6-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh6-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh6-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh6-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh6-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh7-<lambda>-float64_0]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh7-<lambda>-float64_1]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh7-<lambda>-float64_2]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh7-<lambda>-complex128]",
"discretisedfield/tests/test_field.py::test_from_xarray_valid_args_scalar[valid_mesh7-<lambda>-float64_3]",
"discretisedfield/tests/test_field.py::test_from_xarray_invalid_args_and_DataArrays",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[0-2e-10-1-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[0-2e-10-None-1e-10]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p12-p22-1-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p13--2e-09-None-1e-09]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p14-p24-n4-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p15-p25-None-cell5]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p16-p26-n6-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p17-p27-None-cell7]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p18-p28-n8-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p19-p29-None-cell9]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p110-p210-n10-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p111-p211-None-cell11]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p112-p212-n12-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p113-p213-None-cell13]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p114-p214-None-cell14]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p115-p215-n15-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p116-p216-None-cell16]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p117-p217-n17-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p118-p218-None-cell18]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p119-p219-n19-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p120-p220-None-cell20]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p121-p221-n21-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p122-p222-None-cell22]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p123-p223-n23-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p124-p224-None-cell24]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p125-p225-n25-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p126-p226-None-cell26]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p127-p227-n27-None]",
"discretisedfield/tests/test_mesh.py::test_init_valid_args[p128-p228-None-cell28]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[0-2e-10-n0-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[0-2e-10-None-cell1-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[0-0.001-None-1-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p13-p23--1-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p14--2e-10-None--1e-09-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p15--2e-10-seven",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[zero--2e-10-None-1e-09-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p17-p27-n7-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p18-p28-None-cell8-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p19-p29-n9-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p110-p210-None-cell10-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p111-p211-n11-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p112-p212-None-cell12-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p113-p213-n13-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p114-p214-None-cell14-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p115-p215-None-cell15-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p116-p216-n16-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p117-p217-n-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p118-p218-n18-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p119-p219-n19-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p120-p220-None-cell20-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p121-p221-None-cell21-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p122-p222-n22-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p123-p223-None-cell23-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p124-p224-None-cell24-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[string-p225-None-string-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p126-p226-None-(2+2j)-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p127-p227-n27-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[origin-p228-None-cell28-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p129-p229-n29-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p130-p230-None-cell30-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_invalid_args[p131-p231-n31-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_init_subregions[0-50-10-0-40-20-50]",
"discretisedfield/tests/test_mesh.py::test_init_subregions[p11-p21-cell1-sr1_p11-sr1_p21-sr2_p11-sr2_p21]",
"discretisedfield/tests/test_mesh.py::test_init_subregions[p12-p22-cell2-sr1_p12-sr1_p22-sr2_p12-sr2_p22]",
"discretisedfield/tests/test_mesh.py::test_subregions_custom_parameters[p10-50-10-0-40-20-50]",
"discretisedfield/tests/test_mesh.py::test_subregions_custom_parameters[p11-p21-cell1-sr1_p11-sr1_p21-sr2_p11-sr2_p21]",
"discretisedfield/tests/test_mesh.py::test_subregions_custom_parameters[p12-p22-cell2-sr1_p12-sr1_p22-sr2_p12-sr2_p22]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p10-p20-cell0-subregions0-ValueError]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p11-p21-cell1-subregions1-ValueError]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p12-p22-cell2-subregions2-ValueError]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p13-p23-cell3-subregions3-ValueError]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p14-p24-cell4-subregions4-ValueError]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p15-p25-cell5-subregions5-ValueError]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p16-p26-cell6-subregions6-TypeError]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p17-p27-cell7-subregions7-TypeError]",
"discretisedfield/tests/test_mesh.py::test_invalid_subregions[p18-p28-cell8-subregions8-ValueError]",
"discretisedfield/tests/test_mesh.py::test_init_with_region_and_points",
"discretisedfield/tests/test_mesh.py::test_init_with_n_and_cell",
"discretisedfield/tests/test_mesh.py::test_region_not_aggregate_of_cell[0-1.5e-07-4e-09]",
"discretisedfield/tests/test_mesh.py::test_region_not_aggregate_of_cell[p11-p21-cell1]",
"discretisedfield/tests/test_mesh.py::test_region_not_aggregate_of_cell[p12-p22-cell2]",
"discretisedfield/tests/test_mesh.py::test_region_not_aggregate_of_cell[p13-p23-cell3]",
"discretisedfield/tests/test_mesh.py::test_region_not_aggregate_of_cell[p14-p24-cell4]",
"discretisedfield/tests/test_mesh.py::test_region_not_aggregate_of_cell[p15-p25-cell5]",
"discretisedfield/tests/test_mesh.py::test_cell_greater_than_domain[0-1e-09-2e-09]",
"discretisedfield/tests/test_mesh.py::test_cell_greater_than_domain[p11-p21-cell1]",
"discretisedfield/tests/test_mesh.py::test_cell_greater_than_domain[p12-p22-cell2]",
"discretisedfield/tests/test_mesh.py::test_cell_greater_than_domain[p13-p23-cell3]",
"discretisedfield/tests/test_mesh.py::test_cell_greater_than_domain[p14-p24-cell4]",
"discretisedfield/tests/test_mesh.py::test_cell_greater_than_domain[p15-p25-cell5]",
"discretisedfield/tests/test_mesh.py::test_cell_n",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[2e-09-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[None-10-ValueError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[cell2-None-TypeError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[None-n3-TypeError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[cell4-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[None-n5-ValueError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[cell6-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[None-n7-ValueError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[None-n8-TypeError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[None-None-ValueError]",
"discretisedfield/tests/test_mesh.py::test_cell_n_invalid[cell10-n10-ValueError]",
"discretisedfield/tests/test_mesh.py::test_bc",
"discretisedfield/tests/test_mesh.py::test_len[0-5-1-5]",
"discretisedfield/tests/test_mesh.py::test_len[p11-p21-cell1-4]",
"discretisedfield/tests/test_mesh.py::test_len[p12-p22-cell2-60]",
"discretisedfield/tests/test_mesh.py::test_indices_coordinates_iter[p10-p20-n0-5]",
"discretisedfield/tests/test_mesh.py::test_indices_coordinates_iter[p11-p21-n1-15]",
"discretisedfield/tests/test_mesh.py::test_indices_coordinates_iter[p12-p22-n2-30]",
"discretisedfield/tests/test_mesh.py::test_indices_coordinates_iter[p13-p23-n3-120]",
"discretisedfield/tests/test_mesh.py::test_eq[5e-09-6e-09-1e-08-5-3]",
"discretisedfield/tests/test_mesh.py::test_eq[p1_11-p1_21-p21-n11-n21]",
"discretisedfield/tests/test_mesh.py::test_eq[p1_12-p1_22-p22-n12-n22]",
"discretisedfield/tests/test_mesh.py::test_eq[p1_13-p1_23-p23-n13-n23]",
"discretisedfield/tests/test_mesh.py::test_allclose[p1_10-p1_20-p20-5-3]",
"discretisedfield/tests/test_mesh.py::test_allclose[p1_11-p1_21-p21-n11-n21]",
"discretisedfield/tests/test_mesh.py::test_allclose[p1_12-p1_22-p22-n12-n22]",
"discretisedfield/tests/test_mesh.py::test_allclose[p1_13-p1_23-p23-n13-n23]",
"discretisedfield/tests/test_mesh.py::test_allclose_cell_accuracy",
"discretisedfield/tests/test_mesh.py::test_repr",
"discretisedfield/tests/test_mesh.py::test_index2point_valid[p10-p20-n0-2-expected_10-expected_min0-expected_max0]",
"discretisedfield/tests/test_mesh.py::test_index2point_valid[p11-p21-n1-index1-expected_11-expected_min1-expected_max1]",
"discretisedfield/tests/test_mesh.py::test_index2point_valid[p12-p22-n2-index2-expected_12-expected_min2-expected_max2]",
"discretisedfield/tests/test_mesh.py::test_index2point_valid[p13-p23-n3-index3-expected_13-expected_min3-expected_max3]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[0-1-3-3-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[0-1-3--1-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[0-1-3-string-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[0-1-3-0.0-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[0-5-5-index4-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p15-p25-n5-index5-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p16-p26-n6-index6-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p17-p27-n7-index7-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p18-p28-n8-index8-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p19-p29-n9-index9-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p110-p210-n10-index10-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p111-p211-n11-index11-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p112-p212-n12-index12-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p113-p213-n13-index13-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p114-p214-n14-index14-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p115-p215-n15-index15-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p116-p216-n16-index16-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p117-p217-n17-index17-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p118-p218-n18-index18-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p119-p219-n19-index19-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p120-p220-n20-index20-TypeError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[0-1-3-index21-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p122-p222-n22-index22-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p123-p223-n23-index23-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p124-p224-n24-index24-IndexError]",
"discretisedfield/tests/test_mesh.py::test_index2point_invalid[p125-p225-n25-2-IndexError]",
"discretisedfield/tests/test_mesh.py::test_point2index_valid[p10-p20-n0-point0-expected0]",
"discretisedfield/tests/test_mesh.py::test_point2index_valid[p11-p21-n1-point1-expected1]",
"discretisedfield/tests/test_mesh.py::test_point2index_valid[p12-p22-n2-point2-expected2]",
"discretisedfield/tests/test_mesh.py::test_point2index_valid[p13-p23-n3-point3-expected3]",
"discretisedfield/tests/test_mesh.py::test_point2index_boundaries",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[0-1-3-5-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[0-1-3--1-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[0-1-3-string-TypeError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[0-5e-08-5-point3-TypeError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p14-p24-n4-point4-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p15-p25-n5-point5-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p16-p26-n6-point6-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p17-p27-n7-point7-TypeError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p18-p28-n8-point8-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p19-p29-n9-point9-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p110-p210-n10-point10-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p111-p211-n11-point11-TypeError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p112-p212-n12-point12-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p113-p213-n13-point13-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p114-p214-n14-point14-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p115-p215-n15-point15-TypeError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[0-1-3-point16-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p117-p217-n17-point17-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p118-p218-n18-point18-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p119-p219-n19-point19-ValueError]",
"discretisedfield/tests/test_mesh.py::test_point2index_invalid[p120-p220-n20-2-ValueError]",
"discretisedfield/tests/test_mesh.py::test_index2point_point2index_mutually_inverse",
"discretisedfield/tests/test_mesh.py::test_region2slice",
"discretisedfield/tests/test_mesh.py::test_points",
"discretisedfield/tests/test_mesh.py::test_vertices",
"discretisedfield/tests/test_mesh.py::test_line",
"discretisedfield/tests/test_mesh.py::test_or",
"discretisedfield/tests/test_mesh.py::test_is_aligned",
"discretisedfield/tests/test_mesh.py::test_getitem",
"discretisedfield/tests/test_mesh.py::test_getitem_boundaries",
"discretisedfield/tests/test_mesh.py::test_pad[0-10-1]",
"discretisedfield/tests/test_mesh.py::test_pad[p11-p21-cell1]",
"discretisedfield/tests/test_mesh.py::test_pad[p12-p22-cell2]",
"discretisedfield/tests/test_mesh.py::test_pad[p13-p23-cell3]",
"discretisedfield/tests/test_mesh.py::test_getattr[0-100-10-checks0]",
"discretisedfield/tests/test_mesh.py::test_getattr[p11-p21-cell1-checks1]",
"discretisedfield/tests/test_mesh.py::test_getattr[p12-p22-cell2-checks2]",
"discretisedfield/tests/test_mesh.py::test_getattr[p13-p23-cell3-checks3]",
"discretisedfield/tests/test_mesh.py::test_dir[p10-p20-n0-in_dir0-not_in_dir0]",
"discretisedfield/tests/test_mesh.py::test_dir[p11-p21-n1-in_dir1-not_in_dir1]",
"discretisedfield/tests/test_mesh.py::test_dir[p12-p22-n2-in_dir2-not_in_dir2]",
"discretisedfield/tests/test_mesh.py::test_dir[p13-p23-n3-in_dir3-not_in_dir3]",
"discretisedfield/tests/test_mesh.py::test_dV[1-11-2-2]",
"discretisedfield/tests/test_mesh.py::test_dV[p11-p21-cell1-6.25e-18]",
"discretisedfield/tests/test_mesh.py::test_dV[p12-p22-cell2-5]",
"discretisedfield/tests/test_mesh.py::test_dV[p13-p23-cell3-4.5e-35]",
"discretisedfield/tests/test_mesh.py::test_mpl[valid_mesh0]",
"discretisedfield/tests/test_mesh.py::test_mpl[valid_mesh1]",
"discretisedfield/tests/test_mesh.py::test_mpl[valid_mesh2]",
"discretisedfield/tests/test_mesh.py::test_mpl[valid_mesh3]",
"discretisedfield/tests/test_mesh.py::test_mpl[valid_mesh4]",
"discretisedfield/tests/test_mesh.py::test_mpl[valid_mesh5]",
"discretisedfield/tests/test_mesh.py::test_mpl[valid_mesh6]",
"discretisedfield/tests/test_mesh.py::test_mpl[valid_mesh7]",
"discretisedfield/tests/test_mesh.py::test_k3d[valid_mesh0]",
"discretisedfield/tests/test_mesh.py::test_k3d[valid_mesh1]",
"discretisedfield/tests/test_mesh.py::test_k3d[valid_mesh2]",
"discretisedfield/tests/test_mesh.py::test_k3d[valid_mesh3]",
"discretisedfield/tests/test_mesh.py::test_k3d[valid_mesh4]",
"discretisedfield/tests/test_mesh.py::test_k3d[valid_mesh5]",
"discretisedfield/tests/test_mesh.py::test_k3d[valid_mesh6]",
"discretisedfield/tests/test_mesh.py::test_k3d[valid_mesh7]",
"discretisedfield/tests/test_mesh.py::test_k3d_mpl_subregions",
"discretisedfield/tests/test_mesh.py::test_scale",
"discretisedfield/tests/test_mesh.py::test_translate",
"discretisedfield/tests/test_mesh.py::test_slider",
"discretisedfield/tests/test_mesh.py::test_axis_selector",
"discretisedfield/tests/test_mesh.py::test_save_load_subregions[0-100-10]",
"discretisedfield/tests/test_mesh.py::test_save_load_subregions[p11-p21-cell1]",
"discretisedfield/tests/test_mesh.py::test_save_load_subregions[p12-p22-cell2]",
"discretisedfield/tests/test_mesh.py::test_save_load_subregions[p13-p23-cell3]",
"discretisedfield/tests/test_mesh.py::test_coordinate_field[valid_mesh0]",
"discretisedfield/tests/test_mesh.py::test_coordinate_field[valid_mesh1]",
"discretisedfield/tests/test_mesh.py::test_coordinate_field[valid_mesh2]",
"discretisedfield/tests/test_mesh.py::test_coordinate_field[valid_mesh3]",
"discretisedfield/tests/test_mesh.py::test_coordinate_field[valid_mesh4]",
"discretisedfield/tests/test_mesh.py::test_coordinate_field[valid_mesh5]",
"discretisedfield/tests/test_mesh.py::test_coordinate_field[valid_mesh6]",
"discretisedfield/tests/test_mesh.py::test_coordinate_field[valid_mesh7]",
"discretisedfield/tests/test_mesh.py::test_sel_convert_intput",
"discretisedfield/tests/test_mesh.py::test_sel_string_1D",
"discretisedfield/tests/test_mesh.py::test_sel_single[p10-p20-dims0-cell0]",
"discretisedfield/tests/test_mesh.py::test_sel_single[p11-p21-dims1-cell1]",
"discretisedfield/tests/test_mesh.py::test_sel_single[p12-p22-None-cell2]",
"discretisedfield/tests/test_mesh.py::test_sel_range[0-100-dims0-10]",
"discretisedfield/tests/test_mesh.py::test_sel_range[p11-p21-dims1-cell1]",
"discretisedfield/tests/test_mesh.py::test_sel_range[p12-p22-dims2-cell2]",
"discretisedfield/tests/test_mesh.py::test_sel_range[p13-p23-None-cell3]",
"discretisedfield/tests/test_mesh.py::test_sel_subregions",
"discretisedfield/tests/test_mesh.py::test_fftn_mesh",
"discretisedfield/tests/test_mesh.py::test_irfftn_3d[shape0-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_3d[shape1-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_3d[a-TypeError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_3d[shape3-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_3d[shape4-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_3d[10-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_1d[shape0-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_1d[a-TypeError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_1d[shape2-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_1d[shape3-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_1d[shape4-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_1d[17-ValueError]",
"discretisedfield/tests/test_mesh.py::test_irfftn_1d[20-ValueError]",
"discretisedfield/tests/test_region.py::test_init_valid_args[0-2e-10-1]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p11-p21-1]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p12--2e-10-1]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p13-p23-2]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p14-p24-2]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p15-p25-2]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p16-p26-2]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p17-p27-3]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p18-p28-3]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p19-p29-3]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p110-p210-3]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p111-p211-3]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p112-p212-3]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p113-p213-3]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p114-p214-4]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p115-p215-5]",
"discretisedfield/tests/test_region.py::test_init_valid_args[p116-p216-10]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[p10-p20-ValueError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[p11-p21-TypeError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[p12-p22-TypeError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[p13-p23-ValueError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[-1.5e-09-p24-ValueError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[p15-p25-TypeError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[string-p26-TypeError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[abc-def-TypeError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[p18-p28-TypeError]",
"discretisedfield/tests/test_region.py::test_init_invalid_args[p19-p29-TypeError]",
"discretisedfield/tests/test_region.py::test_init_zero_edge_length[1-1.0]",
"discretisedfield/tests/test_region.py::test_init_zero_edge_length[3.141592653589793-p21]",
"discretisedfield/tests/test_region.py::test_init_zero_edge_length[p12-p22]",
"discretisedfield/tests/test_region.py::test_init_zero_edge_length[p13-p23]",
"discretisedfield/tests/test_region.py::test_init_zero_edge_length[p14-p24]",
"discretisedfield/tests/test_region.py::test_init_zero_edge_length[p15-p25]",
"discretisedfield/tests/test_region.py::test_init_zero_edge_length[p16-p26]",
"discretisedfield/tests/test_region.py::test_pmin_pmax_edges_center_volume[0-10-0-10-10-5-10]",
"discretisedfield/tests/test_region.py::test_pmin_pmax_edges_center_volume[0--3e-09--3e-09-0-3e-09--1.5e-09-3e-09]",
"discretisedfield/tests/test_region.py::test_pmin_pmax_edges_center_volume[p12-p22-pmin2-pmax2-edges2-center2-0.000134]",
"discretisedfield/tests/test_region.py::test_pmin_pmax_edges_center_volume[p13-p23-pmin3-pmax3-edges3-center3-165]",
"discretisedfield/tests/test_region.py::test_pmin_pmax_edges_center_volume[p14-p24-pmin4-pmax4-edges4-center4-2e+19]",
"discretisedfield/tests/test_region.py::test_pmin_pmax_edges_center_volume[p15-p25-pmin5-pmax5-edges5-center5-1.425e-24]",
"discretisedfield/tests/test_region.py::test_pmin_pmax_edges_center_volume[p16-p26-pmin6-pmax6-edges6-center6-3628800]",
"discretisedfield/tests/test_region.py::test_repr[-1e-08-1e-08-nm-a-Region(pmin=[-1e-08],",
"discretisedfield/tests/test_region.py::test_repr[p11-p21-units1-dims1-Region(pmin=[0.0,",
"discretisedfield/tests/test_region.py::test_repr[p12-p22-None-None-Region(pmin=[-1.0,",
"discretisedfield/tests/test_region.py::test_repr[p13-p23-None-None-Region(pmin=[0.0,",
"discretisedfield/tests/test_region.py::test_eq[5e-09-6e-09-1e-08]",
"discretisedfield/tests/test_region.py::test_eq[p1_11-p1_21-p21]",
"discretisedfield/tests/test_region.py::test_eq[p1_12-p1_22-p22]",
"discretisedfield/tests/test_region.py::test_allclose[1e-12-p10-p20]",
"discretisedfield/tests/test_region.py::test_allclose[1e-12-p11-p21]",
"discretisedfield/tests/test_region.py::test_allclose[1e-12-p12-p22]",
"discretisedfield/tests/test_region.py::test_allclose[0.001-p10-p20]",
"discretisedfield/tests/test_region.py::test_allclose[0.001-p11-p21]",
"discretisedfield/tests/test_region.py::test_allclose[0.001-p12-p22]",
"discretisedfield/tests/test_region.py::test_contains_1d[None]",
"discretisedfield/tests/test_region.py::test_contains_1d[0.1]",
"discretisedfield/tests/test_region.py::test_contains[p10-p20-None]",
"discretisedfield/tests/test_region.py::test_contains[p10-p20-0.1]",
"discretisedfield/tests/test_region.py::test_contains[p11-p21-None]",
"discretisedfield/tests/test_region.py::test_contains[p11-p21-0.1]",
"discretisedfield/tests/test_region.py::test_contains[p12-p22-None]",
"discretisedfield/tests/test_region.py::test_contains[p12-p22-0.1]",
"discretisedfield/tests/test_region.py::test_contains[p13-p23-None]",
"discretisedfield/tests/test_region.py::test_contains[p13-p23-0.1]",
"discretisedfield/tests/test_region.py::test_facing_surface[p110-p120-p210-p220-x]",
"discretisedfield/tests/test_region.py::test_facing_surface[p111-p121-p211-p221-x]",
"discretisedfield/tests/test_region.py::test_facing_surface[p112-p122-p212-p222-y]",
"discretisedfield/tests/test_region.py::test_facing_surface[p113-p123-p213-p223-x]",
"discretisedfield/tests/test_region.py::test_facing_surface[p114-p124-p214-p224-y]",
"discretisedfield/tests/test_region.py::test_facing_surface[p115-p125-p215-p225-z]",
"discretisedfield/tests/test_region.py::test_facing_surface[p116-p126-p216-p226-x0]",
"discretisedfield/tests/test_region.py::test_facing_surface[p117-p127-p217-p227-x1]",
"discretisedfield/tests/test_region.py::test_facing_surface[p118-p128-p218-p228-x2]",
"discretisedfield/tests/test_region.py::test_facing_surface[p119-p129-p219-p229-x3]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p110-p120-p210-p220]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p111-p121-p211-p221]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p112-p122-p212-p222]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p113-p123-p213-p223]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p114-p124-p214-p224]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p115-p125-p215-p225]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p116-p126-p216-p226]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p117-p127-p217-p227]",
"discretisedfield/tests/test_region.py::test_facing_surface_error[p118-p128-p218-p228]",
"discretisedfield/tests/test_region.py::test_multiplier[region0-1e-09]",
"discretisedfield/tests/test_region.py::test_multiplier[region1-1e-06]",
"discretisedfield/tests/test_region.py::test_scale[-5-5-2--10-10-20]",
"discretisedfield/tests/test_region.py::test_scale[0-10-2--5-15-20]",
"discretisedfield/tests/test_region.py::test_scale[0-10-factor2--5-15-20]",
"discretisedfield/tests/test_region.py::test_scale[p13-p23-0.5-pmin3-pmax3-edges3]",
"discretisedfield/tests/test_region.py::test_scale[p14-p24-2-pmin4-pmax4-edges4]",
"discretisedfield/tests/test_region.py::test_scale[p15-p25-0.5-pmin5-pmax5-edges5]",
"discretisedfield/tests/test_region.py::test_scale[p16-p26-factor6-pmin6-pmax6-edges6]",
"discretisedfield/tests/test_region.py::test_scale[p17-p27-2.5-pmin7-pmax7-edges7]",
"discretisedfield/tests/test_region.py::test_scale_reference[0-10-2-None--5-15]",
"discretisedfield/tests/test_region.py::test_scale_reference[0-10-2-0-0-20]",
"discretisedfield/tests/test_region.py::test_scale_reference[0-10-2-reference_point2--10-10]",
"discretisedfield/tests/test_region.py::test_scale_reference[p13-p23-factor3-reference_point3-pmin3-pmax3]",
"discretisedfield/tests/test_region.py::test_invalid_scale[1-2-two-None-TypeError]",
"discretisedfield/tests/test_region.py::test_invalid_scale[1-2-1-reference_point1-ValueError]",
"discretisedfield/tests/test_region.py::test_invalid_scale[1-2-factor2-None-ValueError]",
"discretisedfield/tests/test_region.py::test_invalid_scale[p13-p23-factor3-None-ValueError]",
"discretisedfield/tests/test_region.py::test_invalid_scale[p14-p24-factor4-None-TypeError]",
"discretisedfield/tests/test_region.py::test_invalid_scale[p15-p25-factor5-1-ValueError]",
"discretisedfield/tests/test_region.py::test_translate[10-0--10--10-0--5-10]",
"discretisedfield/tests/test_region.py::test_translate[0-10-vector1-1.5-11.5-6.5-10]",
"discretisedfield/tests/test_region.py::test_translate[p12-p22-vector2-pmin2-pmax2-center2-edges2]",
"discretisedfield/tests/test_region.py::test_translate[p13-p23-vector3-pmin3-pmax3-center3-edges3]",
"discretisedfield/tests/test_region.py::test_translate[p14-p24-vector4-pmin4-pmax4-center4-edges4]",
"discretisedfield/tests/test_region.py::test_invalid_translate[0-10-vector0-ValueError]",
"discretisedfield/tests/test_region.py::test_invalid_translate[p11-p21-vector1-ValueError]",
"discretisedfield/tests/test_region.py::test_invalid_translate[p12-p22-vector2-ValueError]",
"discretisedfield/tests/test_region.py::test_invalid_translate[p13-p23-3-ValueError]",
"discretisedfield/tests/test_region.py::test_units[0-1-a-m]",
"discretisedfield/tests/test_region.py::test_units[0-1-custom_units1-default_units1]",
"discretisedfield/tests/test_region.py::test_units[p12-p22-custom_units2-default_units2]",
"discretisedfield/tests/test_region.py::test_units[p13-p23-custom_units3-default_units3]",
"discretisedfield/tests/test_region.py::test_units_errors[p10-p20-units0-ValueError]",
"discretisedfield/tests/test_region.py::test_units_errors[p11-p21-units1-TypeError]",
"discretisedfield/tests/test_region.py::test_units_errors[p12-p22-5-TypeError]",
"discretisedfield/tests/test_region.py::test_units_errors[p13-p23-units3-ValueError]",
"discretisedfield/tests/test_region.py::test_units_errors[p14-p24-units4-ValueError]",
"discretisedfield/tests/test_region.py::test_units_errors[p15-p25-units5-TypeError]",
"discretisedfield/tests/test_region.py::test_units_errors[p16-p26-m-ValueError]",
"discretisedfield/tests/test_region.py::test_units_errors[p17-p27-5-TypeError]",
"discretisedfield/tests/test_region.py::test_units_errors[p18-p28-units8-ValueError]",
"discretisedfield/tests/test_region.py::test_units_errors[p19-p29-units9-ValueError]",
"discretisedfield/tests/test_region.py::test_units_errors[p110-p210-units10-TypeError]",
"discretisedfield/tests/test_region.py::test_units_errors[p111-p211-m-ValueError]",
"discretisedfield/tests/test_region.py::test_units_errors[p112-p212-5-TypeError]",
"discretisedfield/tests/test_region.py::test_dims[0-1-a-x]",
"discretisedfield/tests/test_region.py::test_dims[0-1-custom_dims1-default_dims1]",
"discretisedfield/tests/test_region.py::test_dims[p12-p22-custom_dims2-default_dims2]",
"discretisedfield/tests/test_region.py::test_dims[p13-p23-custom_dims3-default_dims3]",
"discretisedfield/tests/test_region.py::test_dims[p14-p24-custom_dims4-default_dims4]",
"discretisedfield/tests/test_region.py::test_dim2index[0-10-None-check_dims0]",
"discretisedfield/tests/test_region.py::test_dim2index[0-10-a-check_dims1]",
"discretisedfield/tests/test_region.py::test_dim2index[p12-p22-dims2-check_dims2]",
"discretisedfield/tests/test_region.py::test_dim2index[p13-p23-dims3-check_dims3]",
"discretisedfield/tests/test_region.py::test_dim2index[p14-p24-dims4-check_dims4]",
"discretisedfield/tests/test_region.py::test_dims_errors[p10-p20-dims0-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p11-p21-dims1-TypeError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p12-p22-5-TypeError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p13-p23-dims3-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p14-p24-dims4-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p15-p25-dims5-TypeError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p16-p26-dims6-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p17-p27-m-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p18-p28-5-TypeError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p19-p29-dims9-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p110-p210-dims10-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p111-p211-dims11-TypeError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p112-p212-dims12-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p113-p213-dims13-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p114-p214-m-ValueError]",
"discretisedfield/tests/test_region.py::test_dims_errors[p115-p215-5-TypeError]",
"discretisedfield/tests/test_region.py::test_pmin_pmax",
"discretisedfield/tests/test_region.py::test_mpl[0-1]",
"discretisedfield/tests/test_region.py::test_mpl[p11-p21]",
"discretisedfield/tests/test_region.py::test_mpl[p12-p22]",
"discretisedfield/tests/test_region.py::test_k3d[0-1]",
"discretisedfield/tests/test_region.py::test_k3d[p11-p21]",
"discretisedfield/tests/test_region.py::test_k3d[p12-p22]"
]
| {
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false
} | 2023-01-18 09:56:41+00:00 | bsd-3-clause | 6,151 |
|
ucbds-infra__otter-grader-296 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0256e918..945fbcb2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ _Changes listed in this section are currently hosted in the `beta` branch on Git
* Added token argument to Otter Generate and Otter Assign
* Implemented submission zip validation against local test cases in `otter.Notebook`
* Removed metadata files for Otter Grade
+* Added flags for disabling file auto-inclusion in Otter Generate
**v2.2.6:**
diff --git a/environment.yml b/environment.yml
index 6ae99487..d284731f 100644
--- a/environment.yml
+++ b/environment.yml
@@ -4,6 +4,8 @@ channels:
- defaults
dependencies:
- python>=3.6
+ - gcc_linux-64
+ - gxx_linux-64
- r-base
- r-essentials
- r-devtools
diff --git a/otter/assign/utils.py b/otter/assign/utils.py
index 988dc41c..e01bb8c6 100644
--- a/otter/assign/utils.py
+++ b/otter/assign/utils.py
@@ -275,7 +275,7 @@ def run_generate_autograder(result, assignment, gs_username, gs_password, plugin
requirements=requirements,
overwrite_requirements=assignment.overwrite_requirements,
environment="environment.yml" if assignment.environment else None,
- no_env=False,
+ no_environment=False,
username=gs_username,
password=gs_password,
files=files,
diff --git a/otter/cli.py b/otter/cli.py
index 4f54028d..29a3bd0a 100644
--- a/otter/cli.py
+++ b/otter/cli.py
@@ -79,10 +79,12 @@ defaults = generate.__kwdefaults__
@click.option("-t", "--tests-path", default=defaults["tests_path"], type=click.Path(exists=True, file_okay=False), help="Path to test files")
@click.option("-o", "--output-dir", default=defaults["output_dir"], type=click.Path(exists=True, file_okay=False), help="Path to which to write zipfile")
@click.option("-c", "--config", type=click.Path(exists=True, file_okay=False), help="Path to otter configuration file; ./otter_config.json automatically checked")
[email protected]("--no-config", is_flag=True, help="Disable auto-inclusion of unspecified Otter config file at ./otter_config.json")
@click.option("-r", "--requirements", type=click.Path(exists=True, file_okay=False), help="Path to requirements.txt file; ./requirements.txt automatically checked")
[email protected]("--no-requirements", is_flag=True, help="Disable auto-inclusion of unespecified requirements file at ./requirements.txt")
@click.option("--overwrite-requirements", is_flag=True, help="Overwrite (rather than append to) default requirements for Gradescope; ignored if no REQUIREMENTS argument")
@click.option("-e", "--environment", type=click.Path(exists=True, file_okay=False), help="Path to environment.yml file; ./environment.yml automatically checked (overwrite)")
[email protected]("--no-env", is_flag=True, help="Whether to ignore an automatically found but unspecified environment.yml file")
[email protected]("--no-environment", is_flag=True, help="Disable auto-inclusion of unespecified environment file at ./environment.yml")
@click.option("-l", "--lang", default=defaults["lang"], type=click.Choice(["python", "r"], case_sensitive=False), help="Assignment programming language; defaults to Python")
@click.option("--username", help="Gradescope username for generating a token")
@click.option("--password", help="Gradescope password for generating a token")
diff --git a/otter/generate/__init__.py b/otter/generate/__init__.py
index 96029c87..592e9c84 100644
--- a/otter/generate/__init__.py
+++ b/otter/generate/__init__.py
@@ -27,9 +27,10 @@ OTTER_ENV_NAME = "otter-env"
OTTR_BRANCH = "1.0.0.b0" # this should match a release tag on GitHub
-def main(*, tests_path="./tests", output_dir="./", config=None, lang="python", requirements=None,
- overwrite_requirements=False, environment=None, no_env=False, username=None, password=None,
- token=None, files=[], assignment=None, plugin_collection=None):
+def main(*, tests_path="./tests", output_dir="./", config=None, no_config=False, lang="python",
+ requirements=None, no_requirements=False, overwrite_requirements=False, environment=None,
+ no_environment=False, username=None, password=None, token=None, files=[], assignment=None,
+ plugin_collection=None):
"""
Runs Otter Generate
@@ -37,12 +38,14 @@ def main(*, tests_path="./tests", output_dir="./", config=None, lang="python", r
tests_path (``str``): path to directory of test files for this assignment
output_dir (``str``): directory in which to write output zip file
config (``str``): path to an Otter configuration JSON file
+ no_config (``bool``): disables auto-inclusion of Otter config file at ./otter_config.json
lang (``str``): the language of the assignment; one of ``["python", "r"]``
requirements (``str``): path to a Python or R requirements file for this assignment
+ no_requirements (``bool``): disables auto-inclusion of requirements file at ./requirements.txt
overwrite_requirements (``bool``): whether to overwrite the default requirements instead of
adding to them
environment (``str``): path to a conda environment file for this assignment
- no_env (``bool``): whether ``./evironment.yml`` should be automatically checked if
+ no_environment (``bool``): whether ``./evironment.yml`` should be automatically checked if
``environment`` is unspecified
username (``str``): a username for Gradescope for generating a token
password (``str``): a password for Gradescope for generating a token
@@ -58,7 +61,7 @@ def main(*, tests_path="./tests", output_dir="./", config=None, lang="python", r
both
"""
# read in otter_config.json
- if config is None and os.path.isfile("otter_config.json"):
+ if config is None and os.path.isfile("otter_config.json") and not no_config:
config = "otter_config.json"
if config is not None and not os.path.isfile(config):
@@ -127,14 +130,18 @@ def main(*, tests_path="./tests", output_dir="./", config=None, lang="python", r
shutil.copy(file, test_dir)
# open requirements if it exists
- with load_default_file(requirements, f"requirements.{'R' if options['lang'] == 'r' else 'txt'}") as reqs:
+ with load_default_file(
+ requirements,
+ f"requirements.{'R' if options['lang'] == 'r' else 'txt'}",
+ default_disabled=no_requirements
+ ) as reqs:
template_context["other_requirements"] = reqs if reqs is not None else ""
template_context["overwrite_requirements"] = overwrite_requirements
# open environment if it exists
# unlike requirements.txt, we will always overwrite, not append by default
- with load_default_file(environment, "environment.yml", default_disabled=no_env) as env_contents:
+ with load_default_file(environment, "environment.yml", default_disabled=no_environment) as env_contents:
template_context["other_environment"] = env_contents
if env_contents is not None:
data = yaml.safe_load(env_contents)
diff --git a/otter/generate/templates/python/environment.yml b/otter/generate/templates/python/environment.yml
index 6670efb8..3d7cf42a 100644
--- a/otter/generate/templates/python/environment.yml
+++ b/otter/generate/templates/python/environment.yml
@@ -6,5 +6,7 @@ dependencies:
- python=3.7
- pip
- nb_conda_kernels
+ - gcc_linux-64
+ - gxx_linux-64
- pip:
- -r requirements.txt{% else %}{{ other_environment }}{% endif %}
\ No newline at end of file
diff --git a/otter/generate/templates/r/environment.yml b/otter/generate/templates/r/environment.yml
index efdffdb8..dc461583 100644
--- a/otter/generate/templates/r/environment.yml
+++ b/otter/generate/templates/r/environment.yml
@@ -6,6 +6,8 @@ dependencies:
- python=3.7
- pip
- nb_conda_kernels
+ - gcc_linux-64
+ - gxx_linux-64
- r-base
- r-essentials
- r-devtools
| ucbds-infra/otter-grader | 723b040e5221052577c5bb350e34741b5d77f8d0 | diff --git a/test/test-assign/gs-autograder-correct/environment.yml b/test/test-assign/gs-autograder-correct/environment.yml
index e1a20111..d1129759 100644
--- a/test/test-assign/gs-autograder-correct/environment.yml
+++ b/test/test-assign/gs-autograder-correct/environment.yml
@@ -6,5 +6,7 @@ dependencies:
- python=3.7
- pip
- nb_conda_kernels
+ - gcc_linux-64
+ - gxx_linux-64
- pip:
- -r requirements.txt
\ No newline at end of file
diff --git a/test/test-assign/rmd-autograder-correct/environment.yml b/test/test-assign/rmd-autograder-correct/environment.yml
index da690492..84806c64 100644
--- a/test/test-assign/rmd-autograder-correct/environment.yml
+++ b/test/test-assign/rmd-autograder-correct/environment.yml
@@ -6,6 +6,8 @@ dependencies:
- python=3.7
- pip
- nb_conda_kernels
+ - gcc_linux-64
+ - gxx_linux-64
- r-base
- r-essentials
- r-devtools
diff --git a/test/test-run/autograder/source/environment.yml b/test/test-run/autograder/source/environment.yml
index e1a20111..d1129759 100644
--- a/test/test-run/autograder/source/environment.yml
+++ b/test/test-run/autograder/source/environment.yml
@@ -6,5 +6,7 @@ dependencies:
- python=3.7
- pip
- nb_conda_kernels
+ - gcc_linux-64
+ - gxx_linux-64
- pip:
- -r requirements.txt
\ No newline at end of file
diff --git a/test/test_generate/test-autograder/autograder-correct/environment.yml b/test/test_generate/test-autograder/autograder-correct/environment.yml
index e1a20111..d1129759 100644
--- a/test/test_generate/test-autograder/autograder-correct/environment.yml
+++ b/test/test_generate/test-autograder/autograder-correct/environment.yml
@@ -6,5 +6,7 @@ dependencies:
- python=3.7
- pip
- nb_conda_kernels
+ - gcc_linux-64
+ - gxx_linux-64
- pip:
- -r requirements.txt
\ No newline at end of file
diff --git a/test/test_generate/test-autograder/autograder-token-correct/environment.yml b/test/test_generate/test-autograder/autograder-token-correct/environment.yml
index e1a20111..d1129759 100644
--- a/test/test_generate/test-autograder/autograder-token-correct/environment.yml
+++ b/test/test_generate/test-autograder/autograder-token-correct/environment.yml
@@ -6,5 +6,7 @@ dependencies:
- python=3.7
- pip
- nb_conda_kernels
+ - gcc_linux-64
+ - gxx_linux-64
- pip:
- -r requirements.txt
\ No newline at end of file
diff --git a/test/test_generate/test_autograder.py b/test/test_generate/test_autograder.py
index b37b2575..62e12f8f 100644
--- a/test/test_generate/test_autograder.py
+++ b/test/test_generate/test_autograder.py
@@ -32,7 +32,7 @@ class TestAutograder(TestCase):
output_dir = TEST_FILES_PATH,
requirements = TEST_FILES_PATH + "requirements.txt",
files = [TEST_FILES_PATH + "data/test-df.csv"],
- no_env = True, # don't use the environment.yml in the root of the repo
+ no_environment = True, # don't use the environment.yml in the root of the repo
)
with self.unzip_to_temp(TEST_FILES_PATH + "autograder.zip", delete=True) as unzipped_dir:
@@ -50,7 +50,7 @@ class TestAutograder(TestCase):
requirements = TEST_FILES_PATH + "requirements.txt",
config = TEST_FILES_PATH + "otter_config.json",
files = [TEST_FILES_PATH + "data/test-df.csv"],
- no_env = True, # don't use the environment.yml in the root of the repo
+ no_environment = True, # don't use the environment.yml in the root of the repo
)
mocked_client.assert_not_called()
diff --git a/test/test_grade.py b/test/test_grade.py
index 9014fe9c..20e29996 100644
--- a/test/test_grade.py
+++ b/test/test_grade.py
@@ -63,7 +63,7 @@ class TestGrade(TestCase):
requirements = TEST_FILES_PATH + "requirements.txt",
output_dir = TEST_FILES_PATH,
config = TEST_FILES_PATH + "otter_config.json" if pdfs else None,
- no_env = True,
+ no_environment = True,
)
def test_docker(self):
| Add flags to disable auto-finding specific files
For example, if you're working in a directory with an `environment.yml` file but don't want Otter Generate to automatically include that in your zip file, there should be a flag to disable that behavior, e.g. `--no-env`. Or a flag that disables _all_ auto-finding. | 0.0 | 723b040e5221052577c5bb350e34741b5d77f8d0 | [
"test/test_generate/test_autograder.py::TestAutograder::test_autograder",
"test/test_generate/test_autograder.py::TestAutograder::test_autograder_with_token"
]
| [
"test/test_generate/test_autograder.py::TestAutograder::test_custom_env"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-08-13 04:33:37+00:00 | bsd-3-clause | 6,152 |
|
ucbds-infra__otter-grader-624 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 600de4fa..d66c12d7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
* Removed deprecated Otter Assign format v0
* Disabled editing for question prompt cells in the notebooks generated by Otter Assign per [#431](https://github.com/ucbds-infra/otter-grader/issues/431)
* Removed `ucbdsinfra/otter-grader` Docker image and made default image for Otter Grade `ubuntu:22.04` per [#534](https://github.com/ucbds-infra/otter-grader/issues/534)
+* Make `xeCJK` opt-in behavior for exporting notebooks via LaTeX per [#548](https://github.com/ucbds-infra/otter-grader/issues/548)
**v4.2.1:**
diff --git a/otter/cli.py b/otter/cli.py
index 08c9b414..779daec6 100644
--- a/otter/cli.py
+++ b/otter/cli.py
@@ -87,7 +87,7 @@ defaults = export.__kwdefaults__
@click.option("--pagebreaks", is_flag=True, help="Whether the PDF should have pagebreaks between questions")
@click.option("-s", "--save", is_flag=True, help="Save intermediate file(s) as well")
@click.option("-e", "--exporter", default=defaults["exporter"], type=click.Choice(["latex", "html"]), help="Type of PDF exporter to use")
[email protected]("--no-xecjk", is_flag=True, help="Force-disable xeCJK in Otter's LaTeX template")
[email protected]("--xecjk", is_flag=True, help="Enable xeCJK in Otter's LaTeX template")
def export_cli(*args, **kwargs):
"""
Export a Jupyter Notebook SRC as a PDF at DEST with optional filtering.
diff --git a/otter/export/__init__.py b/otter/export/__init__.py
index 22f959e1..d1d6f68c 100644
--- a/otter/export/__init__.py
+++ b/otter/export/__init__.py
@@ -45,7 +45,7 @@ def export_notebook(nb_path, dest=None, exporter_type=None, **kwargs):
def main(src, *, dest=None, exporter=None, filtering=False, pagebreaks=False, save=False,
- no_xecjk=False):
+ xecjk=False):
"""
Runs Otter Export
@@ -57,7 +57,7 @@ def main(src, *, dest=None, exporter=None, filtering=False, pagebreaks=False, sa
pagebreaks (``bool``): whether to pagebreak between filtered regions; ignored if ``filtering``
is ``False``
save (``bool``): whether to save any intermediate files (e.g. ``.tex``, ``.html``)
- no_xecjk (``bool``): whether to disable xeCJK in the LaTeX template
+ xecjk (``bool``): whether to use xeCJK in the LaTeX template
"""
export_notebook(
src,
@@ -67,5 +67,5 @@ def main(src, *, dest=None, exporter=None, filtering=False, pagebreaks=False, sa
pagebreaks = pagebreaks,
save_tex = save,
save_html = save,
- no_xecjk=no_xecjk,
+ xecjk=xecjk,
)
diff --git a/otter/export/exporters/via_latex.py b/otter/export/exporters/via_latex.py
index 9ff607d0..fdb6fa63 100644
--- a/otter/export/exporters/via_latex.py
+++ b/otter/export/exporters/via_latex.py
@@ -31,12 +31,9 @@ class PDFViaLatexExporter(BaseExporter):
})
@classmethod
- def convert_notebook(cls, nb_path, dest, xecjk=False, no_xecjk=False, **kwargs):
+ def convert_notebook(cls, nb_path, dest, xecjk=False, **kwargs):
warnings.filterwarnings("ignore", r"invalid escape sequence '\\c'", DeprecationWarning)
- if xecjk and no_xecjk:
- raise ValueError("xeCJK LaTeX template indicated but disallowed")
-
options = cls.default_options.copy()
options.update(kwargs)
@@ -71,17 +68,13 @@ class PDFViaLatexExporter(BaseExporter):
output_file.write(pdf_output[0])
except nbconvert.pdf.LatexFailed as error:
- if not xecjk and not no_xecjk:
- cls.convert_notebook(nb_path, dest, xecjk=True, **kwargs)
-
- else:
- message = "There was an error generating your LaTeX; showing full error message:\n"
- message += indent(error.output, " ")
- if xecjk:
- message += "\n\nIf the error above is related to xeCJK or fandol in LaTeX " \
- "and you don't require this functionality, try running again with " \
- "no_xecjk set to True or the --no-xecjk flag."
- raise ExportFailedException(message)
+ message = "There was an error generating your LaTeX; showing full error message:\n"
+ message += indent(error.output, " ")
+ if xecjk:
+ message += "\n\nIf the error above is related to xeCJK or fandol in LaTeX " \
+ "and you don't require this functionality, try running again without " \
+ "xecjk set to True or the --xecjk flag."
+ raise ExportFailedException(message)
finally:
if NBCONVERT_6:
| ucbds-infra/otter-grader | 29a62b6e598c6efe4be10ad6adaf7a7a2592fe6c | diff --git a/test/test_cli.py b/test/test_cli.py
index 481f0ebb..116a79cf 100644
--- a/test/test_cli.py
+++ b/test/test_cli.py
@@ -215,7 +215,7 @@ def test_export(mocked_export, run_cli):
filtering=False,
pagebreaks=False,
save=False,
- no_xecjk=False,
+ xecjk=False,
)
result = run_cli([*cmd_start])
@@ -242,9 +242,9 @@ def test_export(mocked_export, run_cli):
assert_cli_result(result, expect_error=False)
mocked_export.assert_called_with(**{**std_kwargs, "save": True})
- result = run_cli([*cmd_start, "--no-xecjk"])
+ result = run_cli([*cmd_start, "--xecjk"])
assert_cli_result(result, expect_error=False)
- mocked_export.assert_called_with(**{**std_kwargs, "no_xecjk": True})
+ mocked_export.assert_called_with(**{**std_kwargs, "xecjk": True})
result = run_cli([*cmd_start, "-e", "latex"])
assert_cli_result(result, expect_error=False)
| Make xeCJK opt-in behavior
Make the use of the xeCJK template for Otter Export opt-in only. Currently, if PDF generation fails, Otter Export automatically tries again with xeCJK enabled, and then only shows the error message generated by the xeCJK template. Instead, this retry should not happen automatically, and instead the `xecjk` argument should be used to determine whether to use the xeCJK template or not. This would need to be added as an argument to functions that call Otter Export (e.g. `otter.Notebook.export`). This also means that `no_xecjk`/`--no-xecjk` can be removed. | 0.0 | 29a62b6e598c6efe4be10ad6adaf7a7a2592fe6c | [
"test/test_cli.py::test_export"
]
| [
"test/test_cli.py::test_version",
"test/test_cli.py::test_verbosity",
"test/test_cli.py::test_assign",
"test/test_cli.py::test_check",
"test/test_cli.py::test_generate",
"test/test_cli.py::test_grade",
"test/test_cli.py::test_run"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-04-08 20:07:15+00:00 | bsd-3-clause | 6,153 |
|
ucbds-infra__otter-grader-690 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 18c49b6c..842e16de 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
* Updated default version of `ottr` to v1.4.0
* Added a configuration to require students to acknowledge when a PDF of their notebook cannot be generated when using `Notebook.export` before exporting the zip file per [#599](https://github.com/ucbds-infra/otter-grader/issues/599)
* Added a simple TCP socket server for receiving Otter's logs from the executed notebook to re-enable question logging during Otter Assign per [#589](https://github.com/ucbds-infra/otter-grader/issues/589)
+* Fixed recursive inclusion of files when a directory is in the list passed to the `files` argument of `Notebook.export` per [#620](https://github.com/ucbds-infra/otter-grader/issues/620)
**v5.0.2:**
diff --git a/otter/check/notebook.py b/otter/check/notebook.py
index c67c897d..6d8a63cb 100644
--- a/otter/check/notebook.py
+++ b/otter/check/notebook.py
@@ -411,7 +411,7 @@ class Notebook(Loggable):
for file in files:
if os.path.isdir(file):
- sub_files = glob(f"./{file}/**/*.*")
+ sub_files = glob(f"{file}/**/*.*", recursive=True)
for sub_file in sub_files:
zf.write(sub_file)
else:
| ucbds-infra/otter-grader | 05e451f8a20ebc7bf2b48038ac857f3311982d91 | diff --git a/test/test_check/test_notebook.py b/test/test_check/test_notebook.py
index b5f1347b..a2ca3bf4 100644
--- a/test/test_check/test_notebook.py
+++ b/test/test_check/test_notebook.py
@@ -4,6 +4,7 @@ import datetime as dt
import nbformat as nbf
import os
import pytest
+import shutil
from glob import glob
from textwrap import dedent
@@ -160,6 +161,33 @@ def test_export(mocked_export, mocked_zf, mocked_dt, write_notebook):
# TODO: test display_link
[email protected]("otter.check.notebook.zipfile.ZipFile")
+def test_export_with_directory_in_files(mocked_zf, write_notebook):
+ """
+ Checks that ``Notebook.export`` correctly recurses into subdirectories to find files when a
+ directory is in the list passed to the ``files`` argument.
+ """
+ write_notebook(nbf.v4.new_notebook())
+
+ file_path = FILE_MANAGER.get_path("data/foo.csv")
+ dir_path = os.path.split(file_path)[0]
+ os.makedirs(dir_path, exist_ok=True)
+ with open(file_path, "w+") as f:
+ f.write("hi there")
+
+ try:
+ grader = Notebook(tests_dir=TESTS_DIR)
+ with mock.patch.object(grader, "_resolve_nb_path") as mocked_resolve:
+ mocked_resolve.return_value = NB_PATH
+
+ grader.export(pdf=False, files=[dir_path])
+
+ mocked_zf.return_value.write.assert_any_call(file_path)
+
+ finally:
+ shutil.rmtree(dir_path)
+
+
@mock.patch("otter.check.utils.Button")
@mock.patch("otter.check.utils.HTML")
@mock.patch("otter.check.utils.Output")
| Add files arguments pass in at # ASSIGNMENT CONFIG to Export Cell
**Is your feature request related to a problem? Please describe.**
I found the zipping students' submission feature by `grader.export()` pretty useful. We aim to combine the written LaTeX questions along with the coding question in a single notebook. In order to support students who are not familiar with LaTeX, we want them to insert images into the markdown cell.
**Issue:**
The images are not automatically compressed into the zip file as those are not specified by the `grader.export(files=)` arguments. In addition, in the student version of the notebook, we cannot easily pass on the argument of `files` by the assignment config at the top of the notebook. Plus, the support of passing directories instead of specific file paths.
**Describe the solution you'd like**
Add argument support under `export_cell, files` and pass that to the `grader.export(files=files)`. This should include all the subfiles in the specified directory.
| 0.0 | 05e451f8a20ebc7bf2b48038ac857f3311982d91 | [
"test/test_check/test_notebook.py::test_export_with_directory_in_files"
]
| [
"test/test_check/test_notebook.py::test_check",
"test/test_check/test_notebook.py::test_to_pdf_with_nb_path",
"test/test_check/test_notebook.py::test_export",
"test/test_check/test_notebook.py::test_export_with_no_pdf_ack",
"test/test_check/test_notebook.py::test_colab",
"test/test_check/test_notebook.py::test_jupyterlite",
"test/test_check/test_notebook.py::test_grading_mode"
]
| {
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2023-08-05 19:16:44+00:00 | bsd-3-clause | 6,154 |
|
ukaea__bom_analysis-23 | diff --git a/bom_analysis/base.py b/bom_analysis/base.py
index 1daa145..5c4bc97 100644
--- a/bom_analysis/base.py
+++ b/bom_analysis/base.py
@@ -4,6 +4,7 @@ from pathlib import Path
import os
from getpass import getpass
from typing import Union
+import pprint
import json
import numpy as np
@@ -280,6 +281,9 @@ class MetaConfig(type):
"""
cls._temp_dir = value
change_handler(f"{value}/run.log")
+ run_log.info(
+ f"Configuration Details\n\n{pprint.pformat(cls.to_dict(), indent=4)}"
+ )
@property
def plot_dir(cls):
@@ -407,6 +411,7 @@ class BaseConfigMethods:
isinstance(val, property),
isinstance(val, classmethod),
key in vars(BaseClass).keys(),
+ key == "_login_details",
]
if not any(check):
variables[key] = val
diff --git a/bom_analysis/utils.py b/bom_analysis/utils.py
index 6ade84d..f28c8c7 100644
--- a/bom_analysis/utils.py
+++ b/bom_analysis/utils.py
@@ -12,7 +12,15 @@ import json
import numpy as np
import pandas as pd
-from bom_analysis import ureg, run_log, nice_format, info_handler, Q_
+from bom_analysis import (
+ ureg,
+ run_log,
+ nice_format,
+ info_handler,
+ base_handler,
+ console_handler,
+ Q_,
+)
def __init__(self, inherited_classes):
@@ -137,12 +145,15 @@ def change_handler(new_path):
----------
new_path : str
The new path for the run log to be stored."""
- run_log.removeHandler(info_handler)
+ run_log.handlers.clear()
info_handler.flush()
info_handler.close()
new_info_handler = logging.FileHandler(Path(new_path), "w")
new_info_handler.setLevel(logging.INFO)
new_info_handler.setFormatter(nice_format)
+
+ run_log.addHandler(base_handler)
+ run_log.addHandler(console_handler)
run_log.addHandler(new_info_handler)
| ukaea/bom_analysis | 3b67427e9da6e2c4b1f73467e7713c355bc8924b | diff --git a/tests/test_Base.py b/tests/test_Base.py
index ba7e6d5..7e6e56e 100644
--- a/tests/test_Base.py
+++ b/tests/test_Base.py
@@ -182,6 +182,18 @@ class TestConfig(unittest.TestCase):
con = Config.to_dict()
assert con["b"] == "foo"
+ def test_to_dict_without_login(self):
+ """tests whether to_dict works for different cases"""
+ config = {"a": 1, "b": "foo", "c": "bar"}
+ Config.define_config(config_dict=config)
+ Config._login_details = {
+ "username": "secret",
+ "password": "secret",
+ "domain": "secret",
+ }
+ dump = Config.to_dict()
+ assert "_login_details" not in dump
+
def test_assignment_to_property(self):
Config.restrict_param = "hello"
assert Config.restrict_param == "hello"
diff --git a/tests/test_logging.py b/tests/test_logging.py
index a7fae83..fdbccdb 100644
--- a/tests/test_logging.py
+++ b/tests/test_logging.py
@@ -1,10 +1,15 @@
import unittest
+from unittest.mock import patch
+import tempfile
+
+import pytest
from bom_analysis import run_log
from bom_analysis.utils import change_handler
from bom_analysis.base import BaseConfig
[email protected]
class LoggingTest(unittest.TestCase):
def setUp(self):
change_handler("./run.log")
@@ -44,25 +49,42 @@ class LoggingTest(unittest.TestCase):
content = f.readline()
assert content == "INFO: In ./temp/run.log\n"
- def test_change_location_config(self):
+ @patch("bom_analysis.BaseConfig.to_dict")
+ def test_change_location_config(self, td):
+ td.return_value = {}
run_log.info("Again in ./run.log")
with open("./run.log", "r") as f:
- content = f.readline()
+ content = f.readlines()
- assert content == "INFO: Again in ./run.log\n"
+ assert content[-2] == "INFO: Again in ./run.log\n"
BaseConfig.temp_dir = "./temp/"
run_log.info("Again in ./temp/run.log")
with open("./temp/run.log", "r") as f:
- content = f.readline()
- assert content == "INFO: Again in ./temp/run.log\n"
+ content = f.readlines()
+ assert content[-2] == "INFO: Again in ./temp/run.log\n"
+ with tempfile.TemporaryDirectory(prefix="temp_", dir="./temp/") as tmp_dir:
+ BaseConfig.temp_dir = tmp_dir
+
+ run_log.info("final test in a new dir")
+ with open(f"{tmp_dir}/run.log", "r") as f:
+ content = f.readlines()
+ assert content[-2] == "INFO: final test in a new dir\n"
+ BaseConfig.temp_dir = "./"
+ with open("./temp/run.log", "r") as f:
+ content = f.readlines()
+
+ assert content[-2] == "INFO: Again in ./temp/run.log\n"
with open("./base.log", "r") as f:
base_content = f.readlines()
- assert base_content[-2][26::] == "INFO in test_logging: Again in ./run.log\n"
assert (
- base_content[-1][26::] == "INFO in test_logging: Again in ./temp/run.log\n"
+ base_content[-4][26::] == "INFO in test_logging: final test in a new dir\n"
+ )
+ assert base_content[-12][26::] == "INFO in test_logging: Again in ./run.log\n"
+ assert (
+ base_content[-8][26::] == "INFO in test_logging: Again in ./temp/run.log\n"
)
| correctly remove temporary directory run log handler | 0.0 | 3b67427e9da6e2c4b1f73467e7713c355bc8924b | [
"tests/test_Base.py::TestConfig::test_to_dict_without_login",
"tests/test_logging.py::LoggingTest::test_change_location_config"
]
| [
"tests/test_Base.py::TestBaseClass::test_FromJson",
"tests/test_Base.py::TestBaseClass::test_ToJson",
"tests/test_Base.py::TestBaseClass::test_classfromstring",
"tests/test_Base.py::TestStorageClass::test_AddData",
"tests/test_Base.py::TestStorageClass::test_ToJson",
"tests/test_Base.py::TestStorageClass::test_assign",
"tests/test_Base.py::TestStorageClass::test_compile_all_df",
"tests/test_Base.py::TestStorageClass::test_df",
"tests/test_Base.py::TestConfig::test_BothInput",
"tests/test_Base.py::TestConfig::test_DictInput",
"tests/test_Base.py::TestConfig::test_PathInput",
"tests/test_Base.py::TestConfig::test_assignment_to_property",
"tests/test_Base.py::TestConfig::test_assignment_to_property_with_data_dir_try",
"tests/test_Base.py::TestConfig::test_assignment_to_property_with_data_lib",
"tests/test_Base.py::TestConfig::test_materials_can_not_have_str",
"tests/test_Base.py::TestConfig::test_setattr",
"tests/test_Base.py::TestConfig::test_to_dict",
"tests/test_Base.py::TestOldFormatLoad::test_load_new_correctly",
"tests/test_Base.py::TestOldFormatLoad::test_load_old_correctly",
"tests/test_Base.py::TestBaseDfClass::test_print_correctly",
"tests/test_Base.py::TestBaseDfClass::test_print_correctly_with_pint",
"tests/test_Base.py::TestBaseDfClass::test_print_empty",
"tests/test_logging.py::LoggingTest::test_change_location",
"tests/test_logging.py::LoggingTest::test_debug",
"tests/test_logging.py::LoggingTest::test_no_write_to_run"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-07-08 21:01:25+00:00 | bsd-3-clause | 6,155 |
|
ultrabug__py3status-1221 | diff --git a/py3status/formatter.py b/py3status/formatter.py
index e265819e..db2875de 100644
--- a/py3status/formatter.py
+++ b/py3status/formatter.py
@@ -268,7 +268,9 @@ class Placeholder:
output = u'{%s%s}' % (self.key, self.format)
value = value_ = output.format(**{self.key: value})
- if block.commands.not_zero:
+ if block.parent is None:
+ valid = True
+ elif block.commands.not_zero:
valid = value_ not in ['', 'None', None, False, '0', '0.0', 0, 0.0]
else:
# '', None, and False are ignored
| ultrabug/py3status | dcd3dda64b82e536cfd0233691d374a22e96aeac | diff --git a/tests/test_formatter.py b/tests/test_formatter.py
index 0d1bf9b5..76febab4 100644
--- a/tests/test_formatter.py
+++ b/tests/test_formatter.py
@@ -296,10 +296,18 @@ def test_26():
def test_27():
- run_formatter({'format': '{None}', 'expected': '', })
+ run_formatter({'format': '{None}', 'expected': 'None', })
def test_27a():
+ run_formatter({'format': '{None} {no}', 'expected': 'None False', })
+
+
+def test_27b():
+ run_formatter({'format': '[Hello {None}] {no}', 'expected': ' False', })
+
+
+def test_27c():
run_formatter({'format': '[Hi, my name is {None_str}]', 'expected': '', })
@@ -312,7 +320,7 @@ def test_29():
def test_30():
- run_formatter({'format': '{no}', 'expected': '', })
+ run_formatter({'format': '{no}', 'expected': 'False', })
def test_31():
@@ -1134,7 +1142,7 @@ def test_module_true_value():
def test_module_false_value():
- run_formatter({'format': '{module_false}', 'expected': ''})
+ run_formatter({'format': '{module_false}', 'expected': 'False'})
def test_zero_format_1():
| Formatting returns empty when closing with a False or None placeholder
Formatting returns empty when closing with a `False` or `None` placeholder.
```diff
diff --git a/py3status/modules/static_string.py b/py3status/modules/static_string.py
index dbcec8c6..593b3740 100644
--- a/py3status/modules/static_string.py
+++ b/py3status/modules/static_string.py
@@ -18,10 +18,17 @@ class Py3status:
# available configuration parameters
format = 'Hello, world!'
+ # format = 'A, B, C // {true}' # IS OK | A, B, C // True
+ # format = 'A, B, C // {false}' # IS NOT OK |
+ # format = 'A, B, C // {none}' # IS NOT OK |
+ # format = 'A, B, C // {false} ' # IS OK | A, B, C // False
+ # format = 'A, B, C // {none} ' # IS OK | A, B, C // None
+
def static_string(self):
+ new_dict = {'true': True, 'false': False, 'none': None}
return {
'cached_until': self.py3.CACHE_FOREVER,
- 'full_text': self.py3.safe_format(self.format),
+ 'full_text': self.py3.safe_format(self.format, new_dict),
}
``` | 0.0 | dcd3dda64b82e536cfd0233691d374a22e96aeac | [
"tests/test_formatter.py::test_27",
"tests/test_formatter.py::test_27a",
"tests/test_formatter.py::test_27b",
"tests/test_formatter.py::test_30",
"tests/test_formatter.py::test_module_false_value"
]
| [
"tests/test_formatter.py::test_1",
"tests/test_formatter.py::test_2",
"tests/test_formatter.py::test_3",
"tests/test_formatter.py::test_4",
"tests/test_formatter.py::test_5",
"tests/test_formatter.py::test_6",
"tests/test_formatter.py::test_7",
"tests/test_formatter.py::test_8",
"tests/test_formatter.py::test_9",
"tests/test_formatter.py::test_10",
"tests/test_formatter.py::test_11",
"tests/test_formatter.py::test_12",
"tests/test_formatter.py::test_13",
"tests/test_formatter.py::test_14",
"tests/test_formatter.py::test_15",
"tests/test_formatter.py::test_16",
"tests/test_formatter.py::test_16a",
"tests/test_formatter.py::test_16b",
"tests/test_formatter.py::test_17",
"tests/test_formatter.py::test_18",
"tests/test_formatter.py::test_19",
"tests/test_formatter.py::test_20",
"tests/test_formatter.py::test_21",
"tests/test_formatter.py::test_22",
"tests/test_formatter.py::test_23",
"tests/test_formatter.py::test_24",
"tests/test_formatter.py::test_24a",
"tests/test_formatter.py::test_24b",
"tests/test_formatter.py::test_25",
"tests/test_formatter.py::test_26",
"tests/test_formatter.py::test_27c",
"tests/test_formatter.py::test_28",
"tests/test_formatter.py::test_29",
"tests/test_formatter.py::test_31",
"tests/test_formatter.py::test_32",
"tests/test_formatter.py::test_33",
"tests/test_formatter.py::test_34",
"tests/test_formatter.py::test_35",
"tests/test_formatter.py::test_36",
"tests/test_formatter.py::test_37",
"tests/test_formatter.py::test_38",
"tests/test_formatter.py::test_39",
"tests/test_formatter.py::test_40",
"tests/test_formatter.py::test_41",
"tests/test_formatter.py::test_42",
"tests/test_formatter.py::test_43",
"tests/test_formatter.py::test_44",
"tests/test_formatter.py::test_45",
"tests/test_formatter.py::test_46",
"tests/test_formatter.py::test_47",
"tests/test_formatter.py::test_48",
"tests/test_formatter.py::test_49",
"tests/test_formatter.py::test_50",
"tests/test_formatter.py::test_51",
"tests/test_formatter.py::test_52",
"tests/test_formatter.py::test_53",
"tests/test_formatter.py::test_54",
"tests/test_formatter.py::test_55",
"tests/test_formatter.py::test_56",
"tests/test_formatter.py::test_57",
"tests/test_formatter.py::test_58",
"tests/test_formatter.py::test_58a",
"tests/test_formatter.py::test_59",
"tests/test_formatter.py::test_59a",
"tests/test_formatter.py::test_60",
"tests/test_formatter.py::test_61",
"tests/test_formatter.py::test_62",
"tests/test_formatter.py::test_63",
"tests/test_formatter.py::test_64",
"tests/test_formatter.py::test_65",
"tests/test_formatter.py::test_66",
"tests/test_formatter.py::test_67",
"tests/test_formatter.py::test_68",
"tests/test_formatter.py::test_69",
"tests/test_formatter.py::test_70",
"tests/test_formatter.py::test_70a",
"tests/test_formatter.py::test_71",
"tests/test_formatter.py::test_72",
"tests/test_formatter.py::test_73",
"tests/test_formatter.py::test_74",
"tests/test_formatter.py::test_75",
"tests/test_formatter.py::test_76",
"tests/test_formatter.py::test_77",
"tests/test_formatter.py::test_78",
"tests/test_formatter.py::test_else_true",
"tests/test_formatter.py::test_else_false",
"tests/test_formatter.py::test_color_name_1",
"tests/test_formatter.py::test_color_name_2",
"tests/test_formatter.py::test_color_name_3",
"tests/test_formatter.py::test_color_name_4",
"tests/test_formatter.py::test_color_name_4a",
"tests/test_formatter.py::test_color_name_5",
"tests/test_formatter.py::test_color_name_5a",
"tests/test_formatter.py::test_color_name_6",
"tests/test_formatter.py::test_color_name_7",
"tests/test_formatter.py::test_color_name_7a",
"tests/test_formatter.py::test_color_1",
"tests/test_formatter.py::test_color_1a",
"tests/test_formatter.py::test_color_2",
"tests/test_formatter.py::test_color_3",
"tests/test_formatter.py::test_color_4",
"tests/test_formatter.py::test_color_5",
"tests/test_formatter.py::test_color_6",
"tests/test_formatter.py::test_color_7",
"tests/test_formatter.py::test_color_7a",
"tests/test_formatter.py::test_color_8",
"tests/test_formatter.py::test_color_8a",
"tests/test_formatter.py::test_color_9",
"tests/test_formatter.py::test_color_9a",
"tests/test_formatter.py::test_composite_1",
"tests/test_formatter.py::test_composite_2",
"tests/test_formatter.py::test_composite_3",
"tests/test_formatter.py::test_composite_4",
"tests/test_formatter.py::test_composite_5",
"tests/test_formatter.py::test_composite_6",
"tests/test_formatter.py::test_attr_getter",
"tests/test_formatter.py::test_min_length_1",
"tests/test_formatter.py::test_min_length_2",
"tests/test_formatter.py::test_min_length_3",
"tests/test_formatter.py::test_min_length_4",
"tests/test_formatter.py::test_min_length_5",
"tests/test_formatter.py::test_min_length_6",
"tests/test_formatter.py::test_numeric_strings_1",
"tests/test_formatter.py::test_numeric_strings_2",
"tests/test_formatter.py::test_numeric_strings_3",
"tests/test_formatter.py::test_numeric_strings_4",
"tests/test_formatter.py::test_numeric_strings_5",
"tests/test_formatter.py::test_numeric_strings_6",
"tests/test_formatter.py::test_not_zero_1",
"tests/test_formatter.py::test_not_zero_2",
"tests/test_formatter.py::test_not_zero_3",
"tests/test_formatter.py::test_not_zero_4",
"tests/test_formatter.py::test_not_zero_5",
"tests/test_formatter.py::test_not_zero_6",
"tests/test_formatter.py::test_not_zero_7",
"tests/test_formatter.py::test_not_zero_8",
"tests/test_formatter.py::test_not_zero_9",
"tests/test_formatter.py::test_not_zero_10",
"tests/test_formatter.py::test_not_zero_11",
"tests/test_formatter.py::test_bad_composite_color",
"tests/test_formatter.py::test_soft_1",
"tests/test_formatter.py::test_soft_2",
"tests/test_formatter.py::test_soft_3",
"tests/test_formatter.py::test_soft_4",
"tests/test_formatter.py::test_soft_5",
"tests/test_formatter.py::test_soft_6",
"tests/test_formatter.py::test_soft_7",
"tests/test_formatter.py::test_module_true",
"tests/test_formatter.py::test_module_false",
"tests/test_formatter.py::test_module_true_value",
"tests/test_formatter.py::test_zero_format_1",
"tests/test_formatter.py::test_zero_format_2",
"tests/test_formatter.py::test_zero_format_3",
"tests/test_formatter.py::test_zero_format_4",
"tests/test_formatter.py::test_inherit_not_zero_1",
"tests/test_formatter.py::test_inherit_not_zero_2",
"tests/test_formatter.py::test_inherit_not_zero_3",
"tests/test_formatter.py::test_inherit_show_1",
"tests/test_formatter.py::test_inherit_color_1",
"tests/test_formatter.py::test_inherit_color_2",
"tests/test_formatter.py::test_conditions_1",
"tests/test_formatter.py::test_conditions_2",
"tests/test_formatter.py::test_conditions_3",
"tests/test_formatter.py::test_conditions_4",
"tests/test_formatter.py::test_conditions_5",
"tests/test_formatter.py::test_conditions_6",
"tests/test_formatter.py::test_conditions_7",
"tests/test_formatter.py::test_conditions_8",
"tests/test_formatter.py::test_conditions_9",
"tests/test_formatter.py::test_conditions_10",
"tests/test_formatter.py::test_conditions_11",
"tests/test_formatter.py::test_conditions_12",
"tests/test_formatter.py::test_conditions_13",
"tests/test_formatter.py::test_conditions_14",
"tests/test_formatter.py::test_conditions_15",
"tests/test_formatter.py::test_conditions_16",
"tests/test_formatter.py::test_conditions_17",
"tests/test_formatter.py::test_conditions_18",
"tests/test_formatter.py::test_conditions_19",
"tests/test_formatter.py::test_conditions_20",
"tests/test_formatter.py::test_conditions_21",
"tests/test_formatter.py::test_conditions_22",
"tests/test_formatter.py::test_conditions_23",
"tests/test_formatter.py::test_trailing_zeroes_1",
"tests/test_formatter.py::test_trailing_zeroes_2",
"tests/test_formatter.py::test_ceiling_numbers_1",
"tests/test_formatter.py::test_ceiling_numbers_2"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2018-01-10 08:09:08+00:00 | bsd-3-clause | 6,156 |
|
ultrabug__py3status-1823 | diff --git a/doc/writing_modules.rst b/doc/writing_modules.rst
index 3e431627..e937c295 100644
--- a/doc/writing_modules.rst
+++ b/doc/writing_modules.rst
@@ -27,6 +27,40 @@ which if you are used to XDG_CONFIG paths relates to:
You can also specify the modules location using ``py3status -i <path to custom
modules directory>`` in your i3 configuration file.
+Publishing custom modules on PyPI
+---------------------------------
+
+.. note::
+ Available since py3status version 3.20.
+
+You can share your custom modules and make them available for py3status users even
+if they are not directly part of the py3status main project!
+
+All you have to do is to package your module and publish it to PyPI.
+
+py3status will discover custom modules if they are installed in the same host
+interpreter and if an entry_point in your package ``setup.py`` is defined::
+
+ setup(
+ entry_points={"py3status": ["module = package_name.py3status_module_name"]},
+ )
+
+The awesome `pewpew` module can be taken as an example on how to do it easily:
+
+- Module repository: https://github.com/obestwalter/pew3wm
+- Example setup.py: https://github.com/obestwalter/pew3wm/blob/master/setup.py
+
+We will gladly add ``extra_requires`` pointing to your modules so that users can require
+them while installing py3status. Just open an issue to request this or propose a PR.
+
+If you have installed py3status in a virtualenv (maybe because your custom module
+has dependencies that need to be available) you can also create an installable
+package from your module and publish it on PyPI.
+
+.. note::
+ To clearly identify your py3status package and for others to discover it easily
+ it is recommended to name the PyPI package ``py3status-<your module name>``.
+
Example 1: The basics - Hello World!
------------------------------------
diff --git a/py3status/core.py b/py3status/core.py
index 5e3cd49c..bcfef6ac 100644
--- a/py3status/core.py
+++ b/py3status/core.py
@@ -2,6 +2,7 @@ from __future__ import print_function
from __future__ import division
import os
+import pkg_resources
import sys
import time
@@ -39,6 +40,9 @@ CONFIG_SPECIAL_SECTIONS = [
"py3status",
]
+ENTRY_POINT_NAME = "py3status"
+ENTRY_POINT_KEY = "entry_point"
+
class Runner(Thread):
"""
@@ -421,6 +425,19 @@ class Py3statusWrapper:
return False
def get_user_modules(self):
+ """Mapping from module name to relevant objects.
+
+ There are two ways of discovery and storage:
+ `include_paths` (no installation): include_path, f_name
+ `entry_point` (from installed package): "entry_point", <Py3Status class>
+
+ Modules of the same name from entry points shadow all other modules.
+ """
+ user_modules = self._get_path_based_modules()
+ user_modules.update(self._get_entry_point_based_modules())
+ return user_modules
+
+ def _get_path_based_modules(self):
"""
Search configured include directories for user provided modules.
@@ -438,12 +455,35 @@ class Py3statusWrapper:
if module_name in user_modules:
pass
user_modules[module_name] = (include_path, f_name)
+ self.log(
+ "available module from {}: {}".format(include_path, module_name)
+ )
return user_modules
+ def _get_entry_point_based_modules(self):
+ classes_from_entry_points = {}
+ for entry_point in pkg_resources.iter_entry_points(ENTRY_POINT_NAME):
+ try:
+ module = entry_point.load()
+ except Exception as err:
+ self.log("entry_point '{}' error: {}".format(entry_point, err))
+ continue
+ klass = getattr(module, Module.EXPECTED_CLASS, None)
+ if klass:
+ module_name = entry_point.module_name.split(".")[-1]
+ classes_from_entry_points[module_name] = (ENTRY_POINT_KEY, klass)
+ self.log(
+ "available module from {}: {}".format(ENTRY_POINT_KEY, module_name)
+ )
+ return classes_from_entry_points
+
def get_user_configured_modules(self):
"""
Get a dict of all available and configured py3status modules
in the user's i3status.conf.
+
+ As we already have a convenient way of loading the module, we'll
+ populate the map with the Py3Status class right away
"""
user_modules = {}
if not self.py3_modules:
@@ -451,8 +491,8 @@ class Py3statusWrapper:
for module_name, module_info in self.get_user_modules().items():
for module in self.py3_modules:
if module_name == module.split(" ")[0]:
- include_path, f_name = module_info
- user_modules[module_name] = (include_path, f_name)
+ source, item = module_info
+ user_modules[module_name] = (source, item)
return user_modules
def load_modules(self, modules_list, user_modules):
@@ -460,9 +500,10 @@ class Py3statusWrapper:
Load the given modules from the list (contains instance name) with
respect to the user provided modules dict.
- modules_list: ['weather_yahoo paris', 'net_rate']
+ modules_list: ['weather_yahoo paris', 'pewpew', 'net_rate']
user_modules: {
- 'weather_yahoo': ('/etc/py3status.d/', 'weather_yahoo.py')
+ 'weather_yahoo': ('/etc/py3status.d/', 'weather_yahoo.py'),
+ 'pewpew': (entry_point', <Py3Status class>),
}
"""
for module in modules_list:
@@ -470,7 +511,13 @@ class Py3statusWrapper:
if module in self.modules:
continue
try:
- my_m = Module(module, user_modules, self)
+ instance = None
+ payload = user_modules.get(module)
+ if payload:
+ kind, Klass = payload
+ if kind == ENTRY_POINT_KEY:
+ instance = Klass()
+ my_m = Module(module, user_modules, self, instance=instance)
# only handle modules with available methods
if my_m.methods:
self.modules[module] = my_m
diff --git a/py3status/module.py b/py3status/module.py
index 68c80f5e..15bd285a 100644
--- a/py3status/module.py
+++ b/py3status/module.py
@@ -28,6 +28,7 @@ class Module:
PARAMS_NEW = "new"
PARAMS_LEGACY = "legacy"
+ EXPECTED_CLASS = "Py3status"
def __init__(self, module, user_modules, py3_wrapper, instance=None):
"""
@@ -101,17 +102,16 @@ class Module:
def __repr__(self):
return "<Module {}>".format(self.module_full_name)
- @staticmethod
- def load_from_file(filepath):
+ @classmethod
+ def load_from_file(cls, filepath):
"""
Return user-written class object from given path.
"""
class_inst = None
- expected_class = "Py3status"
module_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])
if file_ext.lower() == ".py":
py_mod = imp.load_source(module_name, filepath)
- if hasattr(py_mod, expected_class):
+ if hasattr(py_mod, cls.EXPECTED_CLASS):
class_inst = py_mod.Py3status()
return class_inst
| ultrabug/py3status | 6ee21ff4cfa4742616752ebdeac787d05b4cbe8e | diff --git a/tests/test_user_modules.py b/tests/test_user_modules.py
new file mode 100644
index 00000000..a1097c4f
--- /dev/null
+++ b/tests/test_user_modules.py
@@ -0,0 +1,55 @@
+import argparse
+import os
+
+import pkg_resources
+import pytest
+
+import py3status
+from py3status.core import Py3statusWrapper, ENTRY_POINT_KEY
+
+
[email protected](name="status_wrapper")
+def make_status_wrapper():
+ args = argparse.Namespace()
+ status_wrapper = Py3statusWrapper(args)
+ return status_wrapper
+
+
+def test__get_path_based_modules(status_wrapper):
+ """Use the list of inbuilt modules as reference to check against."""
+ included_modules_path = os.path.join(os.path.dirname(py3status.__file__), "modules")
+ status_wrapper.options.__dict__["include_paths"] = [included_modules_path]
+ assert os.path.exists(included_modules_path)
+ expected_keys = [
+ n[:-3] for n in os.listdir(included_modules_path) if n.endswith(".py")
+ ]
+ modules = status_wrapper._get_path_based_modules()
+ assert sorted(modules.keys()) == sorted(expected_keys)
+
+
+def test__get_entry_point_based_modules(status_wrapper, monkeypatch):
+ def return_fake_entry_points(*_):
+ class FakePy3status(object):
+ Py3status = "I am a fake class"
+
+ def __init__(self, name):
+ self.name = name
+ self.module_name = "module_name_" + self.name
+
+ @staticmethod
+ def load():
+ from py3status.modules import air_quality
+
+ return air_quality
+
+ return [FakePy3status("spam"), FakePy3status("eggs")]
+
+ monkeypatch.setattr(pkg_resources, "iter_entry_points", return_fake_entry_points)
+
+ user_modules = status_wrapper._get_entry_point_based_modules()
+ assert len(user_modules) == 2
+ for name, info in user_modules.items():
+ assert any(n in name for n in ["spam", "eggs"])
+ kind, klass = info
+ assert kind == ENTRY_POINT_KEY
+ assert klass.__name__ == "Py3status"
| Add possibility to register modules via entry points
As an additional way of adding modules to py3status we can use entry points to find modules that are installed in the same host interpreter like documented [here](https://setuptools.readthedocs.io/en/latest/setuptools.html#dynamic-discovery-of-services-and-plugins).
Advantages of this approach:
* a py3status module can be a real package installable via pip and bring its own dependencies.
* the modules does not need to be contained in one file and does not need to be copied into one of the configuration directories and be free of dependencies
* modules can be developed independently of py3status with a different life cycle from py3status itself | 0.0 | 6ee21ff4cfa4742616752ebdeac787d05b4cbe8e | [
"tests/test_user_modules.py::test__get_path_based_modules",
"tests/test_user_modules.py::test__get_entry_point_based_modules"
]
| []
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2019-07-15 12:10:30+00:00 | bsd-3-clause | 6,157 |
|
uncscode__particula-109 | diff --git a/README.md b/README.md
index f546085..564338c 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,9 @@
Particula is a simple, fast, and powerful particle simulator, or at least two of the three, we hope. It is a simple particle system that is designed to be easy to use and easy to extend. The goal is to have a robust aerosol (gas phase *and* particle phase) simulation system that can be used to answer scientific questions that arise for experiments and research discussions.
-(*DISCLAIMER* [GitHub Copilot](https://copilot.github.com/) is heavily involved in the development of this project and especially in the writing of these paragraphs! _DISCLAIMER_)
+(*DISCLAIMER* [GitHub Copilot](https://copilot.github.com/) is heavily involved in the development of this project and especially in the writing of these paragraphs! *DISCLAIMER*)
-(*WARNING* `particula` is in early and messy development. It is not ready for production use yet, but you are welcome to use it anyway --- even better, you're welcome to contribute! _WARNING_)
+(*WARNING* `particula` is in early and messy development. It is not ready for production use yet, but you are welcome to use it anyway --- even better, you're welcome to contribute! *WARNING*)
## Goals & conduct
diff --git a/particula/__init__.py b/particula/__init__.py
index 74fbd0e..2e8db4a 100644
--- a/particula/__init__.py
+++ b/particula/__init__.py
@@ -19,4 +19,4 @@ from pint import UnitRegistry
# u is the unit registry name.
u = UnitRegistry()
-__version__ = '0.0.4-dev0'
+__version__ = '0.0.4.dev0'
diff --git a/particula/aerosol_dynamics/physical_parameters.py b/particula/aerosol_dynamics/physical_parameters.py
index 11eb5d4..f52a613 100644
--- a/particula/aerosol_dynamics/physical_parameters.py
+++ b/particula/aerosol_dynamics/physical_parameters.py
@@ -1,29 +1,14 @@
-"""centralized location for physical parameters.
+""" A centralized location for physical parameters.
"""
-from particula import u
-
-# Boltzmann's constant in m^2 kg s^-2 K^-1
-BOLTZMANN_CONSTANT = 1.380649e-23 * u.m**2 * u.kg / u.s**2 / u.K
-
-# Avogadro's number
-AVOGADRO_NUMBER = 6.022140857e23 / u.mol
-
-# Gas constant in J mol^-1 K^-1
-GAS_CONSTANT = BOLTZMANN_CONSTANT * AVOGADRO_NUMBER
-
-# elementary charge in C
-ELEMENTARY_CHARGE_VALUE = 1.60217662e-19 * u.C
-
-# Relative permittivity of air at room temperature
-# Previously known as the "dielectric constant"
-# Often denoted as epsilon
-RELATIVE_PERMITTIVITY_AIR = 1.0005 # unitless
-
-# permittivity of free space in F/m
-# Also known as the electric constant, permittivity of free space
-# Often denoted by epsilon_0
-VACUUM_PERMITTIVITY = 8.85418782e-12 * u.F / u.m
-
-# permittivity of air
-ELECTRIC_PERMITTIVITY = RELATIVE_PERMITTIVITY_AIR * VACUUM_PERMITTIVITY
+# pylint: disable=unused-import,
+# flake8: noqa: F401
+from particula.get_constants import (
+ BOLTZMANN_CONSTANT,
+ AVOGADRO_NUMBER,
+ GAS_CONSTANT,
+ ELEMENTARY_CHARGE_VALUE,
+ RELATIVE_PERMITTIVITY_AIR,
+ VACUUM_PERMITTIVITY,
+ ELECTRIC_PERMITTIVITY,
+)
diff --git a/particula/get_constants.py b/particula/get_constants.py
new file mode 100644
index 0000000..c0729f6
--- /dev/null
+++ b/particula/get_constants.py
@@ -0,0 +1,48 @@
+""" A centralized location for important, unchanged physics parameters.
+
+ This file contains constants that are used in multiple modules. Each
+ constant has its own units and exported with them. The constants are
+ mostly related to atmospheric aerosol particles in usual conditions.
+ They are flexible enough to depend on on the temperature and other
+ environmental variablaes (defined in the _environment module). In
+ the event there is an interest in overriding the values of these
+ constants:
+
+ TODO:
+ - Add a way to override the constants by parsing a user-supplied
+ configuration file.
+"""
+
+from particula import u
+
+# Boltzmann's constant in m^2 kg s^-2 K^-1
+BOLTZMANN_CONSTANT = 1.380649e-23 * u.m**2 * u.kg / u.s**2 / u.K
+
+# Avogadro's number
+AVOGADRO_NUMBER = 6.022140857e23 / u.mol
+
+# Gas constant in J mol^-1 K^-1
+GAS_CONSTANT = BOLTZMANN_CONSTANT * AVOGADRO_NUMBER
+
+# elementary charge in C
+ELEMENTARY_CHARGE_VALUE = 1.60217662e-19 * u.C
+
+# Relative permittivity of air at room temperature
+# Previously known as the "dielectric constant"
+# Often denoted as epsilon
+RELATIVE_PERMITTIVITY_AIR = 1.0005 # unitless
+
+# permittivity of free space in F/m
+# Also known as the electric constant, permittivity of free space
+# Often denoted by epsilon_0
+VACUUM_PERMITTIVITY = 8.85418782e-12 * u.F / u.m
+
+# permittivity of air
+ELECTRIC_PERMITTIVITY = RELATIVE_PERMITTIVITY_AIR * VACUUM_PERMITTIVITY
+
+# viscosity of air at 273.15 K
+# these values are used to calculate the dynamic viscosity of air
+REF_VISCOSITY_AIR = 1.716e-5 * u.Pa * u.s
+REF_TEMPERATURE = 273.15 * u.K
+SUTHERLAND_CONSTANT = 110.4 * u.K
+MOLECULAR_WEIGHT_AIR = (28.9644 * u.g / u.mol).to_base_units()
diff --git a/particula/strip_units.py b/particula/strip_units.py
new file mode 100644
index 0000000..031973a
--- /dev/null
+++ b/particula/strip_units.py
@@ -0,0 +1,17 @@
+""" A simple utility to get rid of units if desired.
+"""
+
+from particula import u
+
+
+def unitless(quantity):
+
+ """ This simple utility will return:
+ the magnitude of a quantity if it has units
+ the quantity itself if it does not have units
+ """
+
+ return (
+ quantity.magnitude if isinstance(quantity, u.Quantity)
+ else quantity
+ )
| uncscode/particula | 4a74fab6656fadc314fa9d3ee2b1157620316218 | diff --git a/particula/tests/constants_test.py b/particula/tests/constants_test.py
new file mode 100644
index 0000000..0255a95
--- /dev/null
+++ b/particula/tests/constants_test.py
@@ -0,0 +1,42 @@
+""" Testing getting constants from the get_constants.py file
+"""
+
+from particula import u
+from particula.get_constants import (
+ BOLTZMANN_CONSTANT,
+ AVOGADRO_NUMBER,
+ GAS_CONSTANT,
+)
+
+
+def test_get_constants():
+
+ """ simple tests are conducted as follows:
+
+ * see if GAS_CONSTANT maniuplation is good
+ * see if BOLTZMANN_CONSTANT units are good
+ """
+
+ assert (
+ GAS_CONSTANT
+ ==
+ BOLTZMANN_CONSTANT * AVOGADRO_NUMBER
+ )
+
+ assert (
+ GAS_CONSTANT.units
+ ==
+ BOLTZMANN_CONSTANT.units * AVOGADRO_NUMBER.units
+ )
+
+ assert (
+ GAS_CONSTANT.magnitude
+ ==
+ BOLTZMANN_CONSTANT.magnitude * AVOGADRO_NUMBER.magnitude
+ )
+
+ assert (
+ BOLTZMANN_CONSTANT.units
+ ==
+ u.m**2 * u.kg / u.s**2 / u.K
+ )
diff --git a/particula/tests/unitless_test.py b/particula/tests/unitless_test.py
new file mode 100644
index 0000000..ab6ed65
--- /dev/null
+++ b/particula/tests/unitless_test.py
@@ -0,0 +1,24 @@
+""" A quick test of strip_units.unitless utility
+"""
+
+from particula import u
+from particula.strip_units import unitless
+
+
+def test_strip_units():
+
+ """ testing getting rid of units of an input quantity
+
+ Tests:
+ * see if a quantity with units is stripped
+ * see if a quantity without units is returned
+ * see if manipulation of quantities is also ok
+ """
+
+ assert unitless(1) == 1
+
+ assert unitless(1 * u.kg) == 1
+
+ assert unitless(5 * u.m) == 5
+
+ assert unitless((5 * u.kg) * (1 * u.m)) == 5
| add utility to strip units
- simple utility to return quantities with no units, akin to `.magnitude`. | 0.0 | 4a74fab6656fadc314fa9d3ee2b1157620316218 | [
"particula/tests/constants_test.py::test_get_constants",
"particula/tests/unitless_test.py::test_strip_units"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_added_files",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2022-02-09 17:45:30+00:00 | mit | 6,158 |
|
uncscode__particula-208 | diff --git a/particula/particle.py b/particula/particle.py
index 3b9e2f7..8e85fd2 100644
--- a/particula/particle.py
+++ b/particula/particle.py
@@ -35,7 +35,7 @@ class ParticleDistribution(Vapor):
self.spacing = kwargs.get("spacing", "linspace")
self.nbins = in_scalar(kwargs.get("nbins", 1000)).m
- self.nparticles = in_scalar(kwargs.get("nparticles", 1e5))
+ self.nparticles = in_scalar(kwargs.get("nparticles", 1e5)).m
self.volume = in_volume(kwargs.get("volume", 1e-6))
self.cutoff = in_scalar(kwargs.get("cutoff", 0.9999)).m
self.gsigma = in_scalar(kwargs.get("gsigma", 1.25)).m
@@ -89,7 +89,8 @@ class ParticleDistribution(Vapor):
interval=self.pre_radius(),
disttype="lognormal",
gsigma=self.gsigma,
- mode=self.mode
+ mode=self.mode,
+ nparticles=self.nparticles
)
def pre_distribution(self):
@@ -102,7 +103,9 @@ class ParticleDistribution(Vapor):
mode : geometric mean radius of the particles
"""
- return self.nparticles*self.pre_discretize()/self.volume
+ return np.array(
+ [self.nparticles]
+ ).sum()*self.pre_discretize()/self.volume
class ParticleInstances(ParticleDistribution):
diff --git a/particula/util/distribution_discretization.py b/particula/util/distribution_discretization.py
index 76facea..93a8e43 100644
--- a/particula/util/distribution_discretization.py
+++ b/particula/util/distribution_discretization.py
@@ -11,6 +11,7 @@ def discretize(
disttype="lognormal",
gsigma=in_scalar(1.25).m,
mode=in_radius(100e-9).m,
+ nparticles=in_scalar(1e5).m,
**kwargs
):
""" discretize the distribution of the particles
@@ -30,13 +31,17 @@ def discretize(
if not isinstance(interval, u.Quantity):
interval = u.Quantity(interval, " ")
- if disttype == "lognormal":
- dist = lognorm.pdf(
- x=interval.m,
- s=np.log(gsigma),
- scale=mode,
- )/interval.u
- else:
+ if disttype != "lognormal":
raise ValueError("the 'disttype' must be 'lognormal' for now!")
- return dist
+ return ((
+ lognorm.pdf(
+ x=interval.m,
+ s=np.reshape(np.log(gsigma), (np.array([gsigma]).size, 1)),
+ scale=np.reshape([mode], (np.array([mode]).size, 1)),
+ ) / interval.u
+ * np.reshape([nparticles], (np.array([nparticles]).size, 1))
+ ).sum(axis=0) /
+ np.array([nparticles]).sum() /
+ np.max([np.array([mode]).size, np.array([gsigma]).size])
+ )
diff --git a/particula/util/radius_cutoff.py b/particula/util/radius_cutoff.py
index 2212046..346ce66 100644
--- a/particula/util/radius_cutoff.py
+++ b/particula/util/radius_cutoff.py
@@ -26,10 +26,19 @@ def cut_rad(
_ = kwargs.get("something", None)
- (rad_start, rad_end) = lognorm.interval(
- alpha=cutoff,
- s=np.log(gsigma),
- scale=mode,
- )
+ if np.array([mode]).size == 1:
+ (rad_start, rad_end) = lognorm.interval(
+ alpha=cutoff,
+ s=np.log(gsigma),
+ scale=mode,
+ )
+ else:
+ (rad_start_pre, rad_end_pre) = lognorm.interval(
+ alpha=cutoff,
+ s=np.log(gsigma),
+ scale=mode,
+ )
+ rad_start = rad_start_pre.min()
+ rad_end = rad_end_pre.max()
return (rad_start, rad_end)
| uncscode/particula | 4106b32d5c0dbe9a589a4c9a21d4d10ad627a174 | diff --git a/particula/tests/particle_test.py b/particula/tests/particle_test.py
index 81fb0ce..194b441 100644
--- a/particula/tests/particle_test.py
+++ b/particula/tests/particle_test.py
@@ -49,6 +49,52 @@ standard_environment_ip = environment.Environment(
pressure=101325 * u.Pa,
)
+single_mode = {
+ "mode": 500e-9, # 500 nm median
+ "nbins": 1000, # 1000 bins
+ "nparticles": 1e6, # 1e4 #
+ "volume": 1e-6, # per 1e-6 m^3 (or 1 cc)
+ "gsigma": 1.5, # relatively narrow
+ "spacing": "linspace", # bin spacing,
+}
+
+multi_mode = {
+ "mode": [500e-9, 500e-9], # 500 nm median
+ "nbins": 1000, # 1000 bins
+ "nparticles": [1e6, 1e6], # 1e4 #
+ "volume": 1e-6, # per 1e-6 m^3 (or 1 cc)
+ "gsigma": [1.2, 1.2], # relatively narrow
+ "spacing": "linspace", # bin spacing,
+}
+
+
+def test_particle_distribution():
+ """"Test that the particle distribution is calculated for single mode and
+ multi mode.
+ """
+ def pdf_total(radius, pdf_distribution):
+ return np.trapz(y=pdf_distribution, x=radius)
+
+ # single mode
+ particle_distribution_1 = particle.ParticleDistribution(
+ **single_mode
+ )
+ total_number = pdf_total(
+ particle_distribution_1.pre_radius().m,
+ particle_distribution_1.pre_distribution().m,
+ )
+ assert total_number == pytest.approx(1e12, rel=1e10)
+
+ # multi mode
+ particle_distribution_2 = particle.ParticleDistribution(
+ **multi_mode
+ )
+ total_number2 = pdf_total(
+ particle_distribution_2.pre_radius().m,
+ particle_distribution_2.pre_distribution().m
+ )
+ assert total_number2 == pytest.approx(2e12, rel=1e10)
+
def test_getters():
"""Test that the getters work.
diff --git a/particula/util/tests/distribution_discretization_test.py b/particula/util/tests/distribution_discretization_test.py
index 7c88d68..c99c5be 100644
--- a/particula/util/tests/distribution_discretization_test.py
+++ b/particula/util/tests/distribution_discretization_test.py
@@ -26,3 +26,25 @@ def test_discretize():
discretize(
interval=spans, disttype="linear", gsigma=sigma, mode=modes,
)
+
+
+def test_multi_discretize():
+ """ testing different modes
+ """
+
+ spans = np.linspace(1, 1000, 1000)
+ sigma = 1.25
+ modes = [100, 200]
+
+ assert discretize(
+ interval=spans, disttype="lognormal", gsigma=sigma, mode=modes
+ ).size == spans.size
+
+ assert np.trapz(discretize(
+ interval=spans, disttype="lognormal", gsigma=sigma, mode=modes
+ ), spans) == pytest.approx(1, rel=1e-5)
+
+ with pytest.raises(ValueError):
+ discretize(
+ interval=spans, disttype="linear", gsigma=sigma, mode=modes,
+ )
diff --git a/particula/util/tests/radius_cutoff_test.py b/particula/util/tests/radius_cutoff_test.py
index ae51714..72773d8 100644
--- a/particula/util/tests/radius_cutoff_test.py
+++ b/particula/util/tests/radius_cutoff_test.py
@@ -41,3 +41,56 @@ def test_cuts():
<=
cut_rad(cutoff=.9999, gsigma=1.35, mode=1e-7)[1]
)
+
+
+def test_multi_cuts():
+ """ test case for different modes
+ """
+
+ assert (
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[0]
+ <=
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[1]
+ )
+
+ assert (
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[0]
+ <=
+ cut_rad(cutoff=.9990, gsigma=1.25, mode=[1e-7, 1e-8])[0]
+ )
+
+ assert (
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[1]
+ >=
+ cut_rad(cutoff=.9990, gsigma=1.25, mode=[1e-7, 1e-8])[1]
+ )
+
+ assert (
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[1]
+ <=
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[1]
+ )
+
+ assert (
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[1]
+ ==
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7])[1]
+ )
+
+ assert (
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[1]
+ >=
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-8])[1]
+ )
+
+ assert (
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[0]
+ ==
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-8])[0]
+ )
+
+ assert (
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7, 1e-8])[0]
+ <=
+ cut_rad(cutoff=.9999, gsigma=1.25, mode=[1e-7])[0]
+ )
| allow multi mode dists
allow for kwargs like the following
multi_mode = {
"mode": [5000e-9, 50e-9, 300e-9], # coarse, nano, fine mode
"nbins": 1000, # 1000 bins
"nparticles": [1e6,1e9,1e7], # 1e4 #
"volume": 1e-6, # per 1e-6 m^3 (or 1 cc)
"gsigma": [1.5,1.2,1.5], #
"spacing": "logspace", # bin spacing,
} | 0.0 | 4106b32d5c0dbe9a589a4c9a21d4d10ad627a174 | [
"particula/util/tests/distribution_discretization_test.py::test_multi_discretize"
]
| [
"particula/tests/particle_test.py::test_getters",
"particula/tests/particle_test.py::test_individual_shapes",
"particula/tests/particle_test.py::test_knudsen_number",
"particula/tests/particle_test.py::test_slip_correction_factor",
"particula/tests/particle_test.py::test_friction_factor",
"particula/tests/particle_test.py::test_multiple_shapes",
"particula/tests/particle_test.py::test_big_shapes",
"particula/tests/particle_test.py::test_reduced_mass",
"particula/tests/particle_test.py::test_reduced_friction_factor",
"particula/tests/particle_test.py::test_coulomb_enh",
"particula/util/tests/distribution_discretization_test.py::test_discretize"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-04-05 15:37:03+00:00 | mit | 6,159 |
|
uncscode__particula-56 | diff --git a/.gitignore b/.gitignore
index 8cd503d..edef6da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,9 @@
# ignore local .vscode folder
.vscode/
+# ignore local development folder
+private_dev/
+
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
diff --git a/particula/aerosol_dynamics/parcel.py b/particula/aerosol_dynamics/parcel.py
index 803b541..fa7b3a7 100644
--- a/particula/aerosol_dynamics/parcel.py
+++ b/particula/aerosol_dynamics/parcel.py
@@ -1,45 +1,34 @@
"""
Class for creating a air parcel to put particles and gases in.
"""
-
-from particula.aerosol_dynamics import environment, particle
+import numpy as np
+from particula.aerosol_dynamics import particle, u
class Parcel:
- """Sets the class for creating a parcel.
+ """
+ Creates an air parcel to track and interact with a list of particle objects.
This starts the base for particle and gas dynamic simulations.
- Like the eveolution of a size distribution with time.
- Or change in temperature causing particle evaporation or gas condensation.
+ For example, eveolution of a size distribution with time.
Attributes:
- name (str) The name of the parcel.
- particle_data (list) The radius of the particle.
- enviroment (Environment) The enviroment of the parcel.
- TODO: after enviromnetal class is added to main.
- temperature (float) default: The air temperature in Kelvin.
- pressure (float) default: The air pressure in atm?.
- add gases class
+ name (str) The name of the parcel.
+ particle_data (particle list) Particle objects.
+ enviroment (object) Parcel's enviroment.
"""
- def __init__(self, name: str, temperature=300, pressure=101325):
+ def __init__(self, name: str, parcel_environment):
"""
Constructs the parcel object.
Parameters:
- name (str) The name of the particle.
- particle_data (list) The radius of the particle.
- temperature (float) The air temperature in Kelvin.
- default = 300 K
- pressure (float) The air pressure in Pascals.
- default = 101325 Pa
+ name (str),
+ particle_data (object numpy array),
+ enviroment (object).
"""
self._name = name
- self._particle_data = []
-
- self._enviroment = environment.Environment(
- temperature,
- pressure,
- )
+ self._particle_data = np.array([])
+ self._enviroment = parcel_environment
def name(self) -> str:
"""Returns the name of the parcel."""
@@ -48,62 +37,107 @@ class Parcel:
def add_particle(self, particle_object):
"""Adds a particle to the parcel.
Parameters:
- particle_data (list): The radius of the particle.
+ particle_object (object)
"""
- self._particle_data.append(particle_object)
+ self._particle_data = np.append(self._particle_data, particle_object)
def create_and_add_particle(
- self, name: str, radius, density=1e3, charge=0
+ self, name: str,
+ radius,
+ density=1e3 * u.kg / u.m**3,
+ charge=0 * u.dimensionless
):
- """creats and then Adds a particle to the parcel.
+ """Create and then add a particle to the parcel.
+
Parameters:
- particle_data (list): The radius of the particle.
+ name (str) [no units],
+ radius (float) [m]
+ Optional:
+ density (float) [kg/m**3] default = 1e3 [kg/m**3],
+ charge (int) [dimensionless] default = 0 [dimensionless]
"""
- self._particle_data.append(
+
+ try: # maybe move to particle class
+ radius.check('m')
+ except AttributeError:
+ print('Please add units to radius. E.g., radius = 150 * u.nm]')
+
+ self.add_particle(
particle.Particle(name, radius, density, charge)
)
def create_and_add_list_of_particle(
- self, name_of_particles, radius_of_particles
+ self,
+ name_of_particles,
+ radi_of_particles,
+ densities_of_particles=None,
+ charges_of_particles=None
):
- """Adds a list of particles to the parcel based on size only.
+ """Adds a list of particles to the parcel based on size only (simple).
+ or delcaring denisties and charges (detailed).
Parameters:
- name_of_particles (list): The name of the particles.
- radius_of_particles (list): The radius of the particle.
- TODO: add charge and mass as passible parameters.
+ name_of_particles (str) [no units],
+ radi_of_particles (list) [m]
+ Optional:
+ densities_of_particles (list) [kg/m**3],
+ charges_of_particles (list) [dimensionless]
+ Examples:
+ simple: parcel.create_and_add_list_of_particle(
+ 'org2',
+ [1e-9, 2e-9, 3e-9] * u.m
+ )
+ detailed: create_and_add_list_of_particle(
+ 'org3',
+ [1e-9, 2e-9, 3e-9] * u.m,
+ [1.8, 1, 1] * u.kg / u.m ** 3,
+ [1, 0, 2] * u.dimensionless)
"""
- for size_add in radius_of_particles:
- self.create_and_add_particle(name_of_particles, size_add)
-
- def remove_particle(self, particle_data):
+ if densities_of_particles is None:
+ for size_add in radi_of_particles:
+ self.create_and_add_particle(name_of_particles, size_add)
+ else:
+ for size_add, density_add, charge_add in zip(
+ radi_of_particles,
+ densities_of_particles,
+ charges_of_particles
+ ):
+ self.create_and_add_particle(
+ name_of_particles, size_add, density_add, charge_add
+ )
+
+ def remove_particle(self, particle_index):
"""Removes a particle from the parcel.
Parameters:
- particle_data (list): The radius of the particle.
+ particle_index (list): int or array of ints
"""
- self._particle_data.remove(particle_data)
+ self._particle_data = np.delete(self._particle_data, particle_index)
def remove_all_particles(self):
"""Removes all particles from the parcel."""
- self._particle_data = []
+ self._particle_data = np.array([])
- def particle_classes(self) -> list:
+ def particle_classes_list(self) -> list:
"""Returns the particle data of the parcel."""
return self._particle_data
- def particle_mass(self) -> float:
+ def particle_masses_list(self) -> float:
"""Returns the mass of the particle. Checks units. [kg]"""
- return [i.mass() for i in self.particle_classes()]
+ return [i.mass() for i in self.particle_classes_list()]
- def particle_radius(self) -> float:
+ def particle_radi_list(self) -> float:
"""Returns list of radi of particles"""
- return [i.radius() for i in self.particle_classes()]
+ return [i.radius() for i in self.particle_classes_list()]
+
+ def particle_densities_list(self) -> float:
+ """Returns list of densities of particles."""
+ return [i.density() for i in self.particle_classes_list()]
- def particle_charge(self) -> float:
+ def particle_charges_list(self) -> float:
"""Returns list of charges of particles."""
- return [i.charge() for i in self.particle_classes()]
+ return [i.charge() for i in self.particle_classes_list()]
- def knudsen_number_particle(self) -> float:
+ def particle_knudsen_numbers_list(self) -> float:
"""Returns list of knudsen numbers of particles."""
return [
- i.knudsen_number(self._enviroment) for i in self.particle_classes()
+ i.knudsen_number(self._enviroment) for i in self.particle_classes_list()
]
| uncscode/particula | ead8878fa7ca80122d40e6c9e131f1a93f8e9135 | diff --git a/particula/aerosol_dynamics/parcel_test.py b/particula/aerosol_dynamics/parcel_test.py
index 45222d6..a57080e 100644
--- a/particula/aerosol_dynamics/parcel_test.py
+++ b/particula/aerosol_dynamics/parcel_test.py
@@ -2,7 +2,7 @@
Test suites for parcel class.
"""
-from particula.aerosol_dynamics import parcel, particle
+from particula.aerosol_dynamics import parcel, particle, environment, u
small_particle = particle.Particle(
name="small_particle",
@@ -18,21 +18,96 @@ large_particle = particle.Particle(
charge=1,
)
+standard_environment = environment.Environment(
+ temperature=298 * u.K,
+ pressure=101325 * u.Pa,
+)
+
# create a parcel
-simple_parcel = parcel.Parcel('simple', temperature=300, pressure=101325)
+simple_parcel = parcel.Parcel('simple', standard_environment)
# add single particle to parcel
simple_parcel.add_particle(small_particle)
simple_parcel.add_particle(large_particle)
-simple_parcel.create_and_add_particle('org1', 50e-9)
+simple_parcel.create_and_add_particle('org1', 500*u.nm)
# add multiple particles to parcel
-simple_parcel.create_and_add_list_of_particle('org2', [1e-9, 2e-9, 3e-9])
+simple_parcel.create_and_add_list_of_particle('org2', [1e-9, 2e-9, 3e-9] * u.m)
+simple_parcel.create_and_add_list_of_particle(
+ 'org2', [1e-9, 2e-9, 3e-9] * u.m,
+ [1.8, 1, 1] * u.kg / u.m ** 3, [1, 0, 2] * u.dimensionless
+)
def test_getters():
"""
Test that the getters work by confirming particle creation
"""
- assert len(simple_parcel.particle_classes()) == 6
- assert len(simple_parcel.particle_mass()) == 6
- assert len(simple_parcel.particle_radius()) == 6
+ assert len(simple_parcel.particle_classes_list()) == 9
+ assert len(simple_parcel.particle_masses_list()) == 9
+ assert len(simple_parcel.particle_radi_list()) == 9
+ assert len(simple_parcel.particle_charges_list()) == 9
+
+
+def test_particle_mass_units():
+ '''
+ Test that the mass of the particles is returned in kg
+ '''
+ assert sum(
+ [i.mass().check('kg')
+ for i in simple_parcel.particle_classes_list()]
+ ) == 9
+
+
+def test_particle_radius_units():
+ '''
+ Test that the radius of the particles is returned in m
+ '''
+ assert sum([i.check('m') for i in simple_parcel.particle_radi_list()]) == 9
+
+
+def test_particle_density_units():
+ '''
+ Test that the density of the particles is returned in kg/m^3
+ '''
+ assert sum(
+ [i.check(u.kg / u.m ** 3)
+ for i in simple_parcel.particle_densities_list()]
+ ) == 9
+
+
+def test_particle_charge_units():
+ '''
+ Test that the charge of the particles is returned in dimensionless
+ '''
+ assert sum(
+ [i.check(u.dimensionless)
+ for i in simple_parcel.particle_charges_list()]
+ ) == 9
+
+
+def test_particle_knudsen_number():
+ '''
+ Test that the knudsen number is returned in dimensionless
+ '''
+ assert sum(
+ [i.check(u.dimensionless)
+ for i in simple_parcel.particle_knudsen_numbers_list()]
+ ) == 9
+
+
+def test_remove_particle():
+ '''
+ Test that the remove particle method works
+ '''
+ simple_parcel.remove_particle([0])
+ assert len(simple_parcel.particle_classes_list()) == 8
+ simple_parcel.remove_particle([2, 4])
+ assert len(simple_parcel.particle_classes_list()) == 6
+
+
+def test_remove_all_particles():
+ '''
+ Test that the remove all particles method works
+ '''
+ simple_parcel.remove_all_particles()
+ assert len(simple_parcel.particle_classes_list()) == 0
| come up with unit checks for parcel class
validating parcel methods and linting | 0.0 | ead8878fa7ca80122d40e6c9e131f1a93f8e9135 | [
"particula/aerosol_dynamics/parcel_test.py::test_getters",
"particula/aerosol_dynamics/parcel_test.py::test_particle_mass_units",
"particula/aerosol_dynamics/parcel_test.py::test_particle_radius_units",
"particula/aerosol_dynamics/parcel_test.py::test_particle_density_units",
"particula/aerosol_dynamics/parcel_test.py::test_particle_charge_units",
"particula/aerosol_dynamics/parcel_test.py::test_particle_knudsen_number",
"particula/aerosol_dynamics/parcel_test.py::test_remove_particle",
"particula/aerosol_dynamics/parcel_test.py::test_remove_all_particles"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2021-12-19 19:36:31+00:00 | mit | 6,160 |
|
uncscode__particula-59 | diff --git a/.gitignore b/.gitignore
index 8cd503d..edef6da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,9 @@
# ignore local .vscode folder
.vscode/
+# ignore local development folder
+private_dev/
+
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
diff --git a/particula/aerosol_dynamics/parcel.py b/particula/aerosol_dynamics/parcel.py
index 803b541..fa7b3a7 100644
--- a/particula/aerosol_dynamics/parcel.py
+++ b/particula/aerosol_dynamics/parcel.py
@@ -1,45 +1,34 @@
"""
Class for creating a air parcel to put particles and gases in.
"""
-
-from particula.aerosol_dynamics import environment, particle
+import numpy as np
+from particula.aerosol_dynamics import particle, u
class Parcel:
- """Sets the class for creating a parcel.
+ """
+ Creates an air parcel to track and interact with a list of particle objects.
This starts the base for particle and gas dynamic simulations.
- Like the eveolution of a size distribution with time.
- Or change in temperature causing particle evaporation or gas condensation.
+ For example, eveolution of a size distribution with time.
Attributes:
- name (str) The name of the parcel.
- particle_data (list) The radius of the particle.
- enviroment (Environment) The enviroment of the parcel.
- TODO: after enviromnetal class is added to main.
- temperature (float) default: The air temperature in Kelvin.
- pressure (float) default: The air pressure in atm?.
- add gases class
+ name (str) The name of the parcel.
+ particle_data (particle list) Particle objects.
+ enviroment (object) Parcel's enviroment.
"""
- def __init__(self, name: str, temperature=300, pressure=101325):
+ def __init__(self, name: str, parcel_environment):
"""
Constructs the parcel object.
Parameters:
- name (str) The name of the particle.
- particle_data (list) The radius of the particle.
- temperature (float) The air temperature in Kelvin.
- default = 300 K
- pressure (float) The air pressure in Pascals.
- default = 101325 Pa
+ name (str),
+ particle_data (object numpy array),
+ enviroment (object).
"""
self._name = name
- self._particle_data = []
-
- self._enviroment = environment.Environment(
- temperature,
- pressure,
- )
+ self._particle_data = np.array([])
+ self._enviroment = parcel_environment
def name(self) -> str:
"""Returns the name of the parcel."""
@@ -48,62 +37,107 @@ class Parcel:
def add_particle(self, particle_object):
"""Adds a particle to the parcel.
Parameters:
- particle_data (list): The radius of the particle.
+ particle_object (object)
"""
- self._particle_data.append(particle_object)
+ self._particle_data = np.append(self._particle_data, particle_object)
def create_and_add_particle(
- self, name: str, radius, density=1e3, charge=0
+ self, name: str,
+ radius,
+ density=1e3 * u.kg / u.m**3,
+ charge=0 * u.dimensionless
):
- """creats and then Adds a particle to the parcel.
+ """Create and then add a particle to the parcel.
+
Parameters:
- particle_data (list): The radius of the particle.
+ name (str) [no units],
+ radius (float) [m]
+ Optional:
+ density (float) [kg/m**3] default = 1e3 [kg/m**3],
+ charge (int) [dimensionless] default = 0 [dimensionless]
"""
- self._particle_data.append(
+
+ try: # maybe move to particle class
+ radius.check('m')
+ except AttributeError:
+ print('Please add units to radius. E.g., radius = 150 * u.nm]')
+
+ self.add_particle(
particle.Particle(name, radius, density, charge)
)
def create_and_add_list_of_particle(
- self, name_of_particles, radius_of_particles
+ self,
+ name_of_particles,
+ radi_of_particles,
+ densities_of_particles=None,
+ charges_of_particles=None
):
- """Adds a list of particles to the parcel based on size only.
+ """Adds a list of particles to the parcel based on size only (simple).
+ or delcaring denisties and charges (detailed).
Parameters:
- name_of_particles (list): The name of the particles.
- radius_of_particles (list): The radius of the particle.
- TODO: add charge and mass as passible parameters.
+ name_of_particles (str) [no units],
+ radi_of_particles (list) [m]
+ Optional:
+ densities_of_particles (list) [kg/m**3],
+ charges_of_particles (list) [dimensionless]
+ Examples:
+ simple: parcel.create_and_add_list_of_particle(
+ 'org2',
+ [1e-9, 2e-9, 3e-9] * u.m
+ )
+ detailed: create_and_add_list_of_particle(
+ 'org3',
+ [1e-9, 2e-9, 3e-9] * u.m,
+ [1.8, 1, 1] * u.kg / u.m ** 3,
+ [1, 0, 2] * u.dimensionless)
"""
- for size_add in radius_of_particles:
- self.create_and_add_particle(name_of_particles, size_add)
-
- def remove_particle(self, particle_data):
+ if densities_of_particles is None:
+ for size_add in radi_of_particles:
+ self.create_and_add_particle(name_of_particles, size_add)
+ else:
+ for size_add, density_add, charge_add in zip(
+ radi_of_particles,
+ densities_of_particles,
+ charges_of_particles
+ ):
+ self.create_and_add_particle(
+ name_of_particles, size_add, density_add, charge_add
+ )
+
+ def remove_particle(self, particle_index):
"""Removes a particle from the parcel.
Parameters:
- particle_data (list): The radius of the particle.
+ particle_index (list): int or array of ints
"""
- self._particle_data.remove(particle_data)
+ self._particle_data = np.delete(self._particle_data, particle_index)
def remove_all_particles(self):
"""Removes all particles from the parcel."""
- self._particle_data = []
+ self._particle_data = np.array([])
- def particle_classes(self) -> list:
+ def particle_classes_list(self) -> list:
"""Returns the particle data of the parcel."""
return self._particle_data
- def particle_mass(self) -> float:
+ def particle_masses_list(self) -> float:
"""Returns the mass of the particle. Checks units. [kg]"""
- return [i.mass() for i in self.particle_classes()]
+ return [i.mass() for i in self.particle_classes_list()]
- def particle_radius(self) -> float:
+ def particle_radi_list(self) -> float:
"""Returns list of radi of particles"""
- return [i.radius() for i in self.particle_classes()]
+ return [i.radius() for i in self.particle_classes_list()]
+
+ def particle_densities_list(self) -> float:
+ """Returns list of densities of particles."""
+ return [i.density() for i in self.particle_classes_list()]
- def particle_charge(self) -> float:
+ def particle_charges_list(self) -> float:
"""Returns list of charges of particles."""
- return [i.charge() for i in self.particle_classes()]
+ return [i.charge() for i in self.particle_classes_list()]
- def knudsen_number_particle(self) -> float:
+ def particle_knudsen_numbers_list(self) -> float:
"""Returns list of knudsen numbers of particles."""
return [
- i.knudsen_number(self._enviroment) for i in self.particle_classes()
+ i.knudsen_number(self._enviroment) for i in self.particle_classes_list()
]
diff --git a/particula/aerosol_dynamics/particle.py b/particula/aerosol_dynamics/particle.py
index 491b74e..fdffbb8 100644
--- a/particula/aerosol_dynamics/particle.py
+++ b/particula/aerosol_dynamics/particle.py
@@ -264,26 +264,124 @@ class Particle:
)
return np.sqrt(8 * np.pi) * diffusive_knudsen_number
- # # Gopalkrishnan and Hogan, 2012
- # # doi: https://doi.org/10.1103/PhysRevE.85.026410
- # # Equation 18
- # def dimensionless_coagulation_kernel_GopalkrishnanHogan2012(self, other):
- # diffusive_knudsen_number = self.diffusive_knudsen_number(other)
- # continuum_limit = self.collision_kernel_continuum_limit(other)
- # coulomb_potential_ratio = self.coulomb_potential_ratio(other)
- # # kinetic_limit = self.collision_kernel_kinetic_limit(other)
-
- # return continuum_limit / (
- # 1 + 1.598 * np.minimum(diffusive_knudsen_number,
- # 3*diffusive_knudsen_number / (2*coulomb_potential_ratio)
- # )**1.1709
- # )
-
- # # Gatti and Kortshagen 2008
- # # doi: https://doi.org/10.1103/PhysRevE.78.046402
- # # Retrieved from Gopalkrishnan and Hogan, 2012,
- # # 10.1103/PhysRevE.85.026410,
- # # Equation 13
- # def dimensionless_coagulation_kernel_GattiKortshagen2008(self, other):
- # kernel_hard_sphere =
- # self.dimensionless_coagulation_kernel_hard_sphere(other)
+ @u.wraps(u.dimensionless, [None, None, None, None])
+ def dimensionless_coagulation_kernel_parameterized(
+ self,
+ other,
+ environment: Environment,
+ authors: str = "gh2012",
+ ) -> float:
+ """Dimensionless particle--particle coagulation kernel.
+ Checks units: [dimensionless]
+
+ Paramaters:
+ self: particle 1
+ other: particle 2
+ environment: environment conditions
+ authors: authors of the parameterization
+ - gh2012 https://doi.org/10.1103/PhysRevE.78.046402
+ - cg2020 https://doi.org/XXXXXXXXXXXXXXXXXXXXXXXXXX
+ - hs hard sphere approximation
+ (default: gh2012)
+ """
+
+ if authors == "cg2020":
+ # some parameters
+ corra = 2.5
+ corrb = (
+ 4.528*np.exp(-1088*self.coulomb_potential_ratio(
+ other, environment
+ ))
+ ) + (
+ 0.7091*np.log(1 + 1.527*self.coulomb_potential_ratio(
+ other, environment
+ ))
+ )
+
+ corrc = (11.36)*(self.coulomb_potential_ratio(
+ other, environment
+ )**0.272) - 10.33
+ corrk = - 0.003533*self.coulomb_potential_ratio(
+ other, environment
+ ) + 0.05971
+
+ # mu for the parameterization
+ corr_mu = (corrc/corra)*(
+ (1 + corrk*((np.log(
+ self.diffusive_knudsen_number(other, environment)
+ ) - corrb)/corra))**((-1/corrk) - 1)
+ ) * (
+ np.exp(-(1 + corrk*(np.log(
+ self.diffusive_knudsen_number(other, environment)
+ ) - corrb)/corra)**(- 1/corrk))
+ )
+
+ answer = (
+ self.dimensionless_coagulation_kernel_hard_sphere(
+ other, environment
+ ) if self.coulomb_potential_ratio(
+ other, environment
+ ) <= 0 else
+ self.dimensionless_coagulation_kernel_hard_sphere(
+ other, environment
+ )*np.exp(corr_mu)
+ )
+
+ elif authors == "gh2012":
+ numerator = self.coulomb_enhancement_continuum_limit(
+ other, environment
+ )
+
+ denominator = 1 + 1.598*np.minimum(
+ self.diffusive_knudsen_number(other, environment),
+ 3*self.diffusive_knudsen_number(other, environment)/2
+ / self.coulomb_potential_ratio(other, environment)
+ )
+
+ answer = numerator / denominator
+
+ elif authors == "hs":
+ answer = self.dimensionless_coagulation_kernel_hard_sphere(
+ other, environment
+ )
+
+ if authors not in ["gh2012", "hs", "cg2020"]:
+ raise ValueError("We don't have this parameterization")
+
+ return answer
+
+ @u.wraps(u.m**3 / u.s, [None, None, None, None])
+ def dimensioned_coagulation_kernel(
+ self,
+ other,
+ environment: Environment,
+ authors: str = "hs",
+ ) -> float:
+ """Dimensioned particle--particle coagulation kernel.
+ Checks units: [m**3/s]
+
+ Paramaters:
+ self: particle 1
+ other: particle 2
+ environment: environment conditions
+ authors: authors of the parameterization
+ - gh2012 https://doi.org/10.1103/PhysRevE.78.046402
+ - cg2020 https://doi.org/XXXXXXXXXXXXXXXXXXXXXXXXXX
+ - hs https://doi.org/XXXXXXXXXXXXXXXXXXXXXXXXXX
+ (default: hs)
+ """
+ return (
+ self.dimensionless_coagulation_kernel_parameterized(
+ other, environment, authors
+ ) * self.reduced_friction_factor(
+ other, environment
+ ) * (
+ self.radius() + other.radius()
+ )**3 * self.coulomb_enhancement_kinetic_limit(
+ other, environment
+ )**2 / self.reduced_mass(
+ other
+ ) / self.coulomb_enhancement_continuum_limit(
+ other, environment
+ )
+ )
| uncscode/particula | ead8878fa7ca80122d40e6c9e131f1a93f8e9135 | diff --git a/particula/aerosol_dynamics/parcel_test.py b/particula/aerosol_dynamics/parcel_test.py
index 45222d6..a57080e 100644
--- a/particula/aerosol_dynamics/parcel_test.py
+++ b/particula/aerosol_dynamics/parcel_test.py
@@ -2,7 +2,7 @@
Test suites for parcel class.
"""
-from particula.aerosol_dynamics import parcel, particle
+from particula.aerosol_dynamics import parcel, particle, environment, u
small_particle = particle.Particle(
name="small_particle",
@@ -18,21 +18,96 @@ large_particle = particle.Particle(
charge=1,
)
+standard_environment = environment.Environment(
+ temperature=298 * u.K,
+ pressure=101325 * u.Pa,
+)
+
# create a parcel
-simple_parcel = parcel.Parcel('simple', temperature=300, pressure=101325)
+simple_parcel = parcel.Parcel('simple', standard_environment)
# add single particle to parcel
simple_parcel.add_particle(small_particle)
simple_parcel.add_particle(large_particle)
-simple_parcel.create_and_add_particle('org1', 50e-9)
+simple_parcel.create_and_add_particle('org1', 500*u.nm)
# add multiple particles to parcel
-simple_parcel.create_and_add_list_of_particle('org2', [1e-9, 2e-9, 3e-9])
+simple_parcel.create_and_add_list_of_particle('org2', [1e-9, 2e-9, 3e-9] * u.m)
+simple_parcel.create_and_add_list_of_particle(
+ 'org2', [1e-9, 2e-9, 3e-9] * u.m,
+ [1.8, 1, 1] * u.kg / u.m ** 3, [1, 0, 2] * u.dimensionless
+)
def test_getters():
"""
Test that the getters work by confirming particle creation
"""
- assert len(simple_parcel.particle_classes()) == 6
- assert len(simple_parcel.particle_mass()) == 6
- assert len(simple_parcel.particle_radius()) == 6
+ assert len(simple_parcel.particle_classes_list()) == 9
+ assert len(simple_parcel.particle_masses_list()) == 9
+ assert len(simple_parcel.particle_radi_list()) == 9
+ assert len(simple_parcel.particle_charges_list()) == 9
+
+
+def test_particle_mass_units():
+ '''
+ Test that the mass of the particles is returned in kg
+ '''
+ assert sum(
+ [i.mass().check('kg')
+ for i in simple_parcel.particle_classes_list()]
+ ) == 9
+
+
+def test_particle_radius_units():
+ '''
+ Test that the radius of the particles is returned in m
+ '''
+ assert sum([i.check('m') for i in simple_parcel.particle_radi_list()]) == 9
+
+
+def test_particle_density_units():
+ '''
+ Test that the density of the particles is returned in kg/m^3
+ '''
+ assert sum(
+ [i.check(u.kg / u.m ** 3)
+ for i in simple_parcel.particle_densities_list()]
+ ) == 9
+
+
+def test_particle_charge_units():
+ '''
+ Test that the charge of the particles is returned in dimensionless
+ '''
+ assert sum(
+ [i.check(u.dimensionless)
+ for i in simple_parcel.particle_charges_list()]
+ ) == 9
+
+
+def test_particle_knudsen_number():
+ '''
+ Test that the knudsen number is returned in dimensionless
+ '''
+ assert sum(
+ [i.check(u.dimensionless)
+ for i in simple_parcel.particle_knudsen_numbers_list()]
+ ) == 9
+
+
+def test_remove_particle():
+ '''
+ Test that the remove particle method works
+ '''
+ simple_parcel.remove_particle([0])
+ assert len(simple_parcel.particle_classes_list()) == 8
+ simple_parcel.remove_particle([2, 4])
+ assert len(simple_parcel.particle_classes_list()) == 6
+
+
+def test_remove_all_particles():
+ '''
+ Test that the remove all particles method works
+ '''
+ simple_parcel.remove_all_particles()
+ assert len(simple_parcel.particle_classes_list()) == 0
diff --git a/particula/aerosol_dynamics/particle_test.py b/particula/aerosol_dynamics/particle_test.py
index 1bc50f1..350295f 100644
--- a/particula/aerosol_dynamics/particle_test.py
+++ b/particula/aerosol_dynamics/particle_test.py
@@ -15,27 +15,40 @@ small_particle = particle.Particle(
radius=1.0e-9 * u.m,
density=1.0 * u.kg / u.m**3,
charge=1,
- )
+)
large_particle = particle.Particle(
name="large_particle",
radius=1.0e-7 * u.m,
density=1.8 * u.kg / u.m**3,
charge=1,
- )
+)
invalid_particle = particle.Particle(
name="invalid_particle",
radius=1.0e-7 * u.lb,
density=1 * u.kg / u.m**3,
charge=3 * u.C,
- )
+)
standard_environment = environment.Environment(
temperature=298 * u.K,
pressure=101325 * u.Pa,
)
+negative_ion = particle.Particle(
+ name="negative_ion",
+ radius=0.5e-9 * u.m,
+ density=1.84 * u.kg / u.m**3,
+ charge=-1,
+)
+
+positive_particle = particle.Particle(
+ name="positive_particle",
+ radius=3e-9 * u.m,
+ density=1.7 * u.kg / u.m**3,
+ charge=1,
+)
def test_getters():
"""
@@ -133,3 +146,46 @@ def test_reduced_friction_factor():
large_particle, standard_environment)
assert reduced_friction_factor_1_2 == pytest.approx(3.18e-15)
assert reduced_friction_factor_1_2.check("[mass]/[time]")
+
+
+def test_dimensionless_coagulation_kernel_parameterized():
+ """
+ Test that the paramaterized dimensionless coagulation kernel
+ is calculated correctly.
+ """
+
+ assert small_particle.dimensionless_coagulation_kernel_parameterized(
+ large_particle, standard_environment
+ ) == pytest.approx(0.808, rel=1e-3)
+ assert small_particle.dimensionless_coagulation_kernel_parameterized(
+ large_particle, standard_environment
+ ).check(["None"])
+
+def test_dimensioned_coagulation_kernel():
+ """
+ Test: dimensioned coagulation kernel is calculated correctly.
+ """
+
+ assert small_particle.dimensioned_coagulation_kernel(
+ large_particle, standard_environment
+ ) == pytest.approx(2.738e-10 * u.m**3 / u.s, rel=1e7)
+ assert small_particle.dimensioned_coagulation_kernel(
+ large_particle, standard_environment
+ ).check("[length]**3/[time]")
+
+ # FROM PHYSICS & FIRST PRINCIPLES:
+ # when
+ # negative ion with 1 charge and size 0.5e-9 m
+ # with
+ # positive particle with 1 charge and size 3e-9 m
+ # then:
+ # coagulation should be ~1e-12 m^3/s
+ # (within 2x, or at most an order of magnitude)
+ # (conditions assumed ~300 K, ~1 atm, but don't matter much)
+
+ assert negative_ion.dimensioned_coagulation_kernel(
+ positive_particle, standard_environment
+ ) == pytest.approx(1e-12 * u.m**3 / u.s)
+ assert negative_ion.dimensioned_coagulation_kernel(
+ positive_particle, standard_environment
+ ).check("[length]**3/[time]")
| complete coagulation calculation
- add dimensioned form
- add other options (theories)
- add tests for ion--particle and charged coagulation | 0.0 | ead8878fa7ca80122d40e6c9e131f1a93f8e9135 | [
"particula/aerosol_dynamics/parcel_test.py::test_getters",
"particula/aerosol_dynamics/parcel_test.py::test_particle_mass_units",
"particula/aerosol_dynamics/parcel_test.py::test_particle_radius_units",
"particula/aerosol_dynamics/parcel_test.py::test_particle_density_units",
"particula/aerosol_dynamics/parcel_test.py::test_particle_charge_units",
"particula/aerosol_dynamics/parcel_test.py::test_particle_knudsen_number",
"particula/aerosol_dynamics/parcel_test.py::test_remove_particle",
"particula/aerosol_dynamics/parcel_test.py::test_remove_all_particles",
"particula/aerosol_dynamics/particle_test.py::test_getters",
"particula/aerosol_dynamics/particle_test.py::test_knudsen_number",
"particula/aerosol_dynamics/particle_test.py::test_slip_correction_factor",
"particula/aerosol_dynamics/particle_test.py::test_friction_factor",
"particula/aerosol_dynamics/particle_test.py::test_reduced_mass",
"particula/aerosol_dynamics/particle_test.py::test_reduced_friction_factor",
"particula/aerosol_dynamics/particle_test.py::test_dimensionless_coagulation_kernel_parameterized",
"particula/aerosol_dynamics/particle_test.py::test_dimensioned_coagulation_kernel"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-12-20 02:04:49+00:00 | mit | 6,161 |
|
uncscode__particula-91 | diff --git a/particula/aerosol_dynamics/parcel.py b/particula/aerosol_dynamics/parcel.py
index edd1f2b..1cbab4f 100644
--- a/particula/aerosol_dynamics/parcel.py
+++ b/particula/aerosol_dynamics/parcel.py
@@ -1,21 +1,20 @@
-"""class for creating a air parcel to put particles and gases in.
+"""class for creating an air parcel to put particles and gases into.
"""
import numpy as np
-from particula import u
from particula.aerosol_dynamics import particle
class Parcel:
"""
- Creates an air parcel to track and interact with a list of particle objects.
- This starts the base for particle and gas dynamic simulations.
- For example, eveolution of a size distribution with time.
+ Creates an air parcel to track and interact with a list of particle
+ objects. This is the basis for particle and gas dynamic simulations.
+ For example, evolution of a size distribution with time.
Attributes:
name (str) The name of the parcel.
particle_data (particle list) Particle objects.
- enviroment (object) Parcel's enviroment.
+ environment (object) Parcel's environment.
"""
def __init__(self, name: str, parcel_environment):
@@ -25,11 +24,12 @@ class Parcel:
Parameters:
name (str),
particle_data (object numpy array),
- enviroment (object).
+ environment (object).
"""
self._name = name
self._particle_data = np.array([])
self._enviroment = parcel_environment
+ self.unit_warning_flag = True
def name(self) -> str:
"""Returns the name of the parcel."""
@@ -45,8 +45,8 @@ class Parcel:
def create_and_add_particle(
self, name: str,
radius,
- density=1e3 * u.kg / u.m**3,
- charge=0 * u.dimensionless
+ density=1e3,
+ charge=0
):
"""Create and then add a particle to the parcel.
@@ -57,11 +57,14 @@ class Parcel:
density (float) [kg/m**3] default = 1e3 [kg/m**3],
charge (int) [dimensionless] default = 0 [dimensionless]
"""
-
try: # maybe move to particle class
radius.check('m')
except AttributeError:
- print('Please add units to radius. E.g., radius = 150 * u.nm]')
+ if self.unit_warning_flag:
+ print(
+ "Warning: radius has no units, assuming [m]."
+ )
+ self.unit_warning_flag = False
self.add_particle(
particle.Particle(name, radius, density, charge)
@@ -70,35 +73,35 @@ class Parcel:
def create_and_add_list_of_particle(
self,
name_of_particles,
- radi_of_particles,
+ radii_of_particles,
densities_of_particles=None,
charges_of_particles=None
):
"""Adds a list of particles to the parcel based on size only (simple).
- or delcaring denisties and charges (detailed).
+ or with densities and charges (detailed).
Parameters:
name_of_particles (str) [no units],
- radi_of_particles (list) [m]
+ radii_of_particles (list) [m]
Optional:
densities_of_particles (list) [kg/m**3],
charges_of_particles (list) [dimensionless]
Examples:
simple: parcel.create_and_add_list_of_particle(
'org2',
- [1e-9, 2e-9, 3e-9] * u.m
+ [1e-9, 2e-9, 3e-9]
)
detailed: create_and_add_list_of_particle(
'org3',
- [1e-9, 2e-9, 3e-9] * u.m,
- [1.8, 1, 1] * u.kg / u.m ** 3,
- [1, 0, 2] * u.dimensionless)
+ [1e-9, 2e-9, 3e-9],
+ [1.8e3, 1e3, 1e3],
+ [1, 0, 2])
"""
if densities_of_particles is None:
- for size_add in radi_of_particles:
+ for size_add in radii_of_particles:
self.create_and_add_particle(name_of_particles, size_add)
else:
for size_add, density_add, charge_add in zip(
- radi_of_particles,
+ radii_of_particles,
densities_of_particles,
charges_of_particles
):
@@ -125,8 +128,8 @@ class Parcel:
"""Returns the mass of the particle. Checks units. [kg]"""
return [i.mass() for i in self.particle_classes_list()]
- def particle_radi_list(self) -> float:
- """Returns list of radi of particles"""
+ def particle_radii_list(self) -> float:
+ """Returns list of radii of particles"""
return [i.radius() for i in self.particle_classes_list()]
def particle_densities_list(self) -> float:
@@ -140,5 +143,59 @@ class Parcel:
def particle_knudsen_numbers_list(self) -> float:
"""Returns list of knudsen numbers of particles."""
return [
- i.knudsen_number(self._enviroment) for i in self.particle_classes_list()
+ i.knudsen_number(self._enviroment)
+ for i in self.particle_classes_list()
+ ]
+
+ def particle_dimensioned_coagulation_kernel_list(
+ self,
+ other,
+ authors: str = "cg2019",
+ ) -> float:
+ """Returns list of dimensioned coagulation kernel of given particle
+ (other) to the list of particles in the parcel. [m**3/s]
+ Parameters:
+
+ self: particle_classes_list
+ other: particle 2
+ authors: authors of the parameterization
+ - gh2012 https://doi.org/10.1103/PhysRevE.78.046402
+ - cg2020 https://doi.org/XXXXXXXXXXXXXXXXXXXXXXXXXX
+ - hard_sphere
+ (default: cg2019)
+ """
+ return [
+ i.dimensioned_coagulation_kernel(other, self._enviroment, authors)
+ for i in self.particle_classes_list()
]
+
+ def particle_dimensionless_coagulation_kernel_list(
+ self,
+ other,
+ authors: str = "cg2019",
+ ) -> float:
+ """Returns list of dimensioned coagulation kernel of given particle
+ (other) to the list of particles in the parcel. [m**3/s]
+ Parameters:
+
+ self: particle_classes_list
+ other: particle 2
+ authors: authors of the parameterization
+ - gh2012 https://doi.org/10.1103/PhysRevE.78.046402
+ - cg2020 https://doi.org/XXXXXXXXXXXXXXXXXXXXXXXXXX
+ - hard_sphere
+ (default: cg2019)
+ """
+ return [
+ i.dimensionless_coagulation_kernel_parameterized(
+ other, self._enviroment, authors
+ )
+ for i in self.particle_classes_list()
+ ]
+
+
+def get_magnitude_only(list_of_properties) -> float:
+ """strips units from the numpy array and returns the magnitude."""
+ return [
+ i.magnitude for i in list_of_properties
+ ]
| uncscode/particula | 444965b63cfd269b6f65d14f1fe765d82ad66242 | diff --git a/particula/aerosol_dynamics/tests/parcel_test.py b/particula/aerosol_dynamics/tests/parcel_test.py
index eedb634..26f6cbd 100644
--- a/particula/aerosol_dynamics/tests/parcel_test.py
+++ b/particula/aerosol_dynamics/tests/parcel_test.py
@@ -19,8 +19,8 @@ large_particle = particle.Particle(
)
standard_environment = environment.Environment(
- temperature=298 * u.K,
- pressure=101325 * u.Pa,
+ temperature=298,
+ pressure=101325,
)
# create a parcel
@@ -29,12 +29,12 @@ simple_parcel = parcel.Parcel('simple', standard_environment)
# add single particle to parcel
simple_parcel.add_particle(small_particle)
simple_parcel.add_particle(large_particle)
-simple_parcel.create_and_add_particle('org1', 500*u.nm)
+simple_parcel.create_and_add_particle('org1', 500)
# add multiple particles to parcel
-simple_parcel.create_and_add_list_of_particle('org2', [1e-9, 2e-9, 3e-9] * u.m)
+simple_parcel.create_and_add_list_of_particle('org2', [1e-9, 2e-9, 3e-9])
simple_parcel.create_and_add_list_of_particle(
- 'org2', [1e-9, 2e-9, 3e-9] * u.m,
- [1.8, 1, 1] * u.kg / u.m ** 3, [1, 0, 2] * u.dimensionless
+ 'org2', [1e-9, 2e-9, 3e-9],
+ [1.8, 1, 1], [1, 0, 2]
)
@@ -44,8 +44,18 @@ def test_getters():
"""
assert len(simple_parcel.particle_classes_list()) == 9
assert len(simple_parcel.particle_masses_list()) == 9
- assert len(simple_parcel.particle_radi_list()) == 9
+ assert len(simple_parcel.particle_radii_list()) == 9
assert len(simple_parcel.particle_charges_list()) == 9
+ assert len(
+ simple_parcel.particle_dimensioned_coagulation_kernel_list(
+ large_particle
+ )
+ ) == 9
+ assert len(
+ simple_parcel.particle_dimensionless_coagulation_kernel_list(
+ large_particle
+ )
+ ) == 9
def test_particle_mass_units():
@@ -62,7 +72,9 @@ def test_particle_radius_units():
'''
Test that the radius of the particles is returned in m
'''
- assert sum([i.check('m') for i in simple_parcel.particle_radi_list()]) == 9
+ assert sum(
+ [i.check('m') for i in simple_parcel.particle_radii_list()]
+ ) == 9
def test_particle_density_units():
@@ -95,6 +107,33 @@ def test_particle_knudsen_number():
) == 9
+def test_particle_dimensioned_coagulation_kernel_list():
+ '''
+ Test that the dimensioned coagulation kernel list is returned in m^3/s
+ '''
+ assert sum(
+ [i.check(u.m ** 3 / u.s)
+ for i in
+ simple_parcel.particle_dimensioned_coagulation_kernel_list(
+ large_particle
+ )]
+ ) == 9
+
+
+def test_particle_dimensionless_coagulation_kernel_list():
+ '''
+ Test that the dimensionless coagulation kernel list is returned
+ in dimensionless
+ '''
+ assert sum(
+ [i.check(u.dimensionless)
+ for i in
+ simple_parcel.particle_dimensionless_coagulation_kernel_list(
+ large_particle
+ )]
+ ) == 9
+
+
def test_remove_particle():
'''
Test that the remove particle method works
| add particle to particle interacations in parcel class
https://github.com/uncscode/particula/blob/85ba3f80b2f6d5b7d87c0e9f1a848d1bb9d86e94/aerosol_dynamics/parcel.py#L98 | 0.0 | 444965b63cfd269b6f65d14f1fe765d82ad66242 | [
"particula/aerosol_dynamics/tests/parcel_test.py::test_getters",
"particula/aerosol_dynamics/tests/parcel_test.py::test_particle_mass_units",
"particula/aerosol_dynamics/tests/parcel_test.py::test_particle_radius_units",
"particula/aerosol_dynamics/tests/parcel_test.py::test_particle_dimensioned_coagulation_kernel_list",
"particula/aerosol_dynamics/tests/parcel_test.py::test_particle_dimensionless_coagulation_kernel_list"
]
| [
"particula/aerosol_dynamics/tests/parcel_test.py::test_particle_density_units",
"particula/aerosol_dynamics/tests/parcel_test.py::test_particle_charge_units",
"particula/aerosol_dynamics/tests/parcel_test.py::test_particle_knudsen_number",
"particula/aerosol_dynamics/tests/parcel_test.py::test_remove_particle",
"particula/aerosol_dynamics/tests/parcel_test.py::test_remove_all_particles"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-01-17 21:07:33+00:00 | mit | 6,162 |
|
ungarj__mapchete-466 | diff --git a/mapchete/_executor.py b/mapchete/_executor.py
index e1f9d53..2478b0d 100644
--- a/mapchete/_executor.py
+++ b/mapchete/_executor.py
@@ -11,7 +11,7 @@ import warnings
from cached_property import cached_property
-from mapchete.errors import JobCancelledError
+from mapchete.errors import JobCancelledError, MapcheteTaskFailed
from mapchete.log import set_log_level
from mapchete._timer import Timer
@@ -180,21 +180,15 @@ class _ExecutorBase:
Release future from cluster explicitly and wrap result around FinishedFuture object.
"""
if not _dask:
- try:
- self.running_futures.remove(future)
- except KeyError: # pragma: no cover
- pass
+ self.running_futures.discard(future)
self.finished_futures.discard(future)
- fut_exception = future.exception(timeout=FUTURE_TIMEOUT)
- if fut_exception: # pragma: no cover
- logger.error("exception caught in future %s", future)
- logger.exception(fut_exception)
- raise fut_exception
- result = result or future.result(timeout=FUTURE_TIMEOUT)
- if isinstance(result, CancelledError): # pragma: no cover
- raise result
+
+ # raise exception if future errored or was cancelled
+ future = future_raise_exception(future)
+
# create minimal Future-like object with no references to the cluster
finished_future = FinishedFuture(future, result=result)
+
# explicitly release future
try:
future.release()
@@ -253,7 +247,7 @@ class DaskExecutor(_ExecutorBase):
"starting dask.distributed.Client with kwargs %s", self._executor_kwargs
)
self._ac_iterator = as_completed(
- loop=self._executor.loop, with_results=True, raise_errors=True
+ loop=self._executor.loop, with_results=True, raise_errors=False
)
self._submitted = 0
super().__init__(*args, **kwargs)
@@ -608,14 +602,14 @@ class FakeFuture:
except Exception as e: # pragma: no cover
self._result, self._exception = None, e
- def result(self):
+ def result(self, **kwargs):
"""Return task result."""
if self._exception:
logger.exception(self._exception)
raise self._exception
return self._result
- def exception(self):
+ def exception(self, **kwargs):
"""Raise task exception if any."""
return self._exception
@@ -635,11 +629,11 @@ class SkippedFuture:
self._result = result
self.skip_info = skip_info
- def result(self):
+ def result(self, **kwargs):
"""Only return initial result value."""
return self._result
- def exception(self): # pragma: no cover
+ def exception(self, **kwargs): # pragma: no cover
"""Nothing to raise here."""
return
@@ -665,14 +659,14 @@ class FinishedFuture:
except Exception as e: # pragma: no cover
self._result, self._exception = None, e
- def result(self):
+ def result(self, **kwargs):
"""Return task result."""
if self._exception: # pragma: no cover
logger.exception(self._exception)
raise self._exception
return self._result
- def exception(self): # pragma: no cover
+ def exception(self, **kwargs): # pragma: no cover
"""Raise task exception if any."""
return self._exception
@@ -683,3 +677,57 @@ class FinishedFuture:
def __repr__(self): # pragma: no cover
"""Return string representation."""
return f"<FinishedFuture: type: {type(self._result)}, exception: {type(self._exception)})"
+
+
+def future_is_failed_or_cancelled(future):
+ """
+ Return whether future is failed or cancelled.
+
+ This is a workaround between the slightly different APIs of dask and concurrent.futures.
+ It also tries to avoid potentially expensive calls to the dask scheduler.
+ """
+ # dask futures
+ if hasattr(future, "status"):
+ return future.status in ["error", "cancelled"]
+ # concurrent.futures futures
+ else:
+ return future.exception(timeout=FUTURE_TIMEOUT) is not None
+
+
+def future_exception(future):
+ """
+ Return future exception if future errored or cancelled.
+
+ This is a workaround between the slightly different APIs of dask and concurrent.futures.
+ It also tries to avoid potentially expensive calls to the dask scheduler.
+ """
+ # dask futures
+ if hasattr(future, "status"):
+ if future.status == "cancelled": # pragma: no cover
+ exception = future.result(timeout=FUTURE_TIMEOUT)
+ elif future.status == "error":
+ exception = future.exception(timeout=FUTURE_TIMEOUT)
+ else: # pragma: no cover
+ exception = None
+ else:
+ # concurrent.futures futures
+ exception = future.exception(timeout=FUTURE_TIMEOUT)
+
+ if exception is None: # pragma: no cover
+ raise TypeError("future %s does not have an exception to raise", future)
+ return exception
+
+
+def future_raise_exception(future, raise_errors=True):
+ """
+ Checks whether future contains an exception and raises it.
+ """
+ if raise_errors and future_is_failed_or_cancelled(future):
+ exception = future_exception(future)
+ future_name = (
+ future.key.rstrip("_finished") if hasattr(future, "key") else str(future)
+ )
+ raise MapcheteTaskFailed(
+ f"{future_name} raised a {repr(exception)}"
+ ).with_traceback(exception.__traceback__)
+ return future
diff --git a/mapchete/_processing.py b/mapchete/_processing.py
index 97e8a32..997d6ea 100644
--- a/mapchete/_processing.py
+++ b/mapchete/_processing.py
@@ -5,18 +5,28 @@ from contextlib import ExitStack
from itertools import chain
import logging
import multiprocessing
+import os
from shapely.geometry import mapping
from tilematrix._funcs import Bounds
from traceback import format_exc
from typing import Generator
from mapchete.config import get_process_func
-from mapchete._executor import DaskExecutor, Executor, SkippedFuture, FinishedFuture
-from mapchete.errors import MapcheteNodataTile
-from mapchete._tasks import to_dask_collection, TileTaskBatch, TileTask, TaskBatch, Task
+from mapchete._executor import (
+ DaskExecutor,
+ Executor,
+ SkippedFuture,
+ FinishedFuture,
+ future_raise_exception,
+)
+from mapchete.errors import MapcheteNodataTile, MapcheteTaskFailed
+from mapchete._tasks import to_dask_collection, TileTaskBatch, TileTask, TaskBatch
from mapchete._timer import Timer
from mapchete.validate import validate_zooms
+FUTURE_TIMEOUT = float(os.environ.get("MP_FUTURE_TIMEOUT", 10))
+
+
logger = logging.getLogger(__name__)
@@ -279,16 +289,8 @@ def compute(
),
1,
):
- if raise_errors: # pragma: no cover
- if future.exception():
- logger.exception(future.exception())
- raise future.exception()
- elif future.cancelled():
- logger.debug("future %s was cancelled!", future)
- # this should raise the CancelledError
- future.result()
logger.debug("task %s finished: %s", num_processed, future)
- yield future
+ yield future_raise_exception(future, raise_errors=raise_errors)
else:
for num_processed, future in enumerate(
_compute_tasks(
@@ -301,16 +303,8 @@ def compute(
),
1,
):
- if raise_errors: # pragma: no cover
- if future.exception():
- logger.exception(future.exception())
- raise future.exception()
- elif future.cancelled():
- logger.debug("future %s was cancelled!", future)
- # this should raise the CancelledError
- future.result()
logger.debug("task %s finished: %s", num_processed, future)
- yield future
+ yield future_raise_exception(future)
logger.info("computed %s tasks in %s", num_processed, duration)
@@ -571,7 +565,6 @@ def _compute_task_graph(
):
# TODO optimize memory management, e.g. delete preprocessing tasks from input
# once the dask graph is ready.
- from dask.delayed import delayed
from distributed import as_completed
# materialize all tasks including dependencies
@@ -587,7 +580,6 @@ def _compute_task_graph(
)
)
logger.debug("dask collection with %s tasks generated in %s", len(coll), t)
-
# send to scheduler
with Timer() as t:
futures = executor._executor.compute(coll, optimize_graph=True, traverse=True)
@@ -635,6 +627,7 @@ def _compute_tasks(
fkwargs=dict(append_data=True),
**kwargs,
):
+ future = future_raise_exception(future)
result = future.result()
process.config.set_preprocessing_task_result(result.task_key, result.data)
yield future
@@ -642,22 +635,21 @@ def _compute_tasks(
# run single tile
if tile:
logger.info("run process on single tile")
- yield next(
- executor.as_completed(
- func=_execute_and_write,
- iterable=[
- TileTask(
- tile=tile,
- config=process.config,
- skip=(
- process.config.mode == "continue"
- and process.config.output_reader.tiles_exist(tile)
- ),
+ for future in executor.as_completed(
+ func=_execute_and_write,
+ iterable=[
+ TileTask(
+ tile=tile,
+ config=process.config,
+ skip=(
+ process.config.mode == "continue"
+ and process.config.output_reader.tiles_exist(tile)
),
- ],
- fkwargs=dict(output_writer=process.config.output),
- )
- )
+ ),
+ ],
+ fkwargs=dict(output_writer=process.config.output),
+ ):
+ yield future_raise_exception(future)
else:
# for output drivers requiring writing data in parent process
@@ -689,7 +681,7 @@ def _compute_tasks(
write_in_parent_process=write_in_parent_process,
**kwargs,
):
- yield future
+ yield future_raise_exception(future)
def _run_multi_overviews(
diff --git a/mapchete/_tasks.py b/mapchete/_tasks.py
index 43f9c26..22ca296 100644
--- a/mapchete/_tasks.py
+++ b/mapchete/_tasks.py
@@ -232,6 +232,7 @@ class TileTask(Task):
# append dependent preprocessing task results to input objects
if dependencies:
for task_key, task_result in dependencies.items():
+ logger.debug("HERBERT: %s", task_key)
if not task_key.startswith("tile_task"):
inp_key, task_key = task_key.split(":")[0], ":".join(
task_key.split(":")[1:]
@@ -259,9 +260,7 @@ class TileTask(Task):
# Log process time
logger.exception(e)
logger.error((self.tile.id, "exception in user process", e, str(duration)))
- new = MapcheteProcessException(format_exc())
- new.old = e
- raise new
+ raise
return process_data
@@ -424,8 +423,16 @@ def to_dask_collection(batches):
)
else:
dependencies = {}
- tasks[task] = delayed(batch.func)(
- task, dependencies=dependencies, **batch.fkwargs
+ tasks[task] = delayed(
+ batch.func,
+ pure=True,
+ name=f"{task.id}",
+ traverse=len(dependencies) > 0,
+ )(
+ task,
+ dependencies=dependencies,
+ **batch.fkwargs,
+ dask_key_name=f"{task.id}_finished",
)
previous_batch = batch
return list(tasks.values())
diff --git a/mapchete/errors.py b/mapchete/errors.py
index 6576a7e..675897e 100644
--- a/mapchete/errors.py
+++ b/mapchete/errors.py
@@ -13,6 +13,10 @@ class MapcheteProcessException(Exception):
"""Raised when a mapchete process execution fails."""
+class MapcheteTaskFailed(Exception):
+ """Raised when a task fails."""
+
+
class MapcheteProcessOutputError(ValueError):
"""Raised when a mapchete process output is invalid."""
| ungarj/mapchete | cfb5e80f613869af774cffdbefbf7416568a4174 | diff --git a/test/test_errors.py b/test/test_errors.py
index 0d0a4db..f286b95 100644
--- a/test/test_errors.py
+++ b/test/test_errors.py
@@ -276,7 +276,7 @@ def test_process_exception(mp_tmpdir, cleantopo_br, process_error_py):
config = cleantopo_br.dict
config.update(process=process_error_py)
with mapchete.open(config) as mp:
- with pytest.raises(errors.MapcheteProcessException):
+ with pytest.raises(AssertionError):
mp.execute((5, 0, 0))
diff --git a/test/test_executor.py b/test/test_executor.py
index 6e65bb7..b89807e 100644
--- a/test/test_executor.py
+++ b/test/test_executor.py
@@ -1,7 +1,9 @@
import pytest
import time
+import mapchete
from mapchete import Executor, SkippedFuture
+from mapchete.errors import MapcheteTaskFailed
from mapchete._executor import FakeFuture
@@ -230,3 +232,61 @@ def test_fake_future():
with pytest.raises(RuntimeError):
future.result()
assert future.exception()
+
+
+def test_process_exception_tile(mp_tmpdir, cleantopo_br, process_error_py):
+ """Assert process exception is raised."""
+ config = cleantopo_br.dict
+ config.update(process=process_error_py)
+ with mapchete.open(config) as mp:
+ with pytest.raises(MapcheteTaskFailed):
+ list(mp.compute(tile=(5, 0, 0), concurrency="processes"))
+
+
+def test_process_exception_tile_dask(mp_tmpdir, cleantopo_br, process_error_py):
+ """Assert process exception is raised."""
+ config = cleantopo_br.dict
+ config.update(process=process_error_py)
+ with mapchete.open(config) as mp:
+ with pytest.raises(MapcheteTaskFailed):
+ list(
+ mp.compute(tile=(5, 0, 0), concurrency="dask", dask_compute_graph=True)
+ )
+
+
+def test_process_exception_tile_dask_nograph(mp_tmpdir, cleantopo_br, process_error_py):
+ """Assert process exception is raised."""
+ config = cleantopo_br.dict
+ config.update(process=process_error_py)
+ with mapchete.open(config) as mp:
+ with pytest.raises(MapcheteTaskFailed):
+ list(
+ mp.compute(tile=(5, 0, 0), concurrency="dask", dask_compute_graph=False)
+ )
+
+
+def test_process_exception_zoom(mp_tmpdir, cleantopo_br, process_error_py):
+ """Assert process exception is raised."""
+ config = cleantopo_br.dict
+ config.update(process=process_error_py)
+ with mapchete.open(config) as mp:
+ with pytest.raises(MapcheteTaskFailed):
+ list(mp.compute(zoom=5, concurrency="processes"))
+
+
+def test_process_exception_zoom_dask(mp_tmpdir, cleantopo_br, process_error_py):
+ """Assert process exception is raised."""
+ config = cleantopo_br.dict
+ config.update(process=process_error_py)
+ with mapchete.open(config) as mp:
+ with pytest.raises(MapcheteTaskFailed):
+ list(mp.compute(zoom=5, concurrency="dask", dask_compute_graph=True))
+
+
+def test_process_exception_zoom_dask_nograph(mp_tmpdir, cleantopo_br, process_error_py):
+ """Assert process exception is raised."""
+ config = cleantopo_br.dict
+ config.update(process=process_error_py)
+ with mapchete.open(config) as mp:
+ with pytest.raises(MapcheteTaskFailed):
+ list(mp.compute(zoom=5, concurrency="dask", dask_compute_graph=False))
| add information which task failed upon exception
e.g. process tile id or preprocessing task id | 0.0 | cfb5e80f613869af774cffdbefbf7416568a4174 | [
"test/test_errors.py::test_mapchete_init",
"test/test_errors.py::test_config_modes",
"test/test_errors.py::test_execute",
"test/test_errors.py::test_write",
"test/test_errors.py::test_get_raw_output",
"test/test_errors.py::test_metatiles",
"test/test_errors.py::test_no_cli_input_file",
"test/test_errors.py::test_wrong_bounds",
"test/test_errors.py::test_empty_input_files",
"test/test_errors.py::test_mandatory_params",
"test/test_errors.py::test_invalid_output_params",
"test/test_errors.py::test_invalid_zoom_levels",
"test/test_errors.py::test_zoom_dependend_functions",
"test/test_errors.py::test_validate_values",
"test/test_errors.py::test_input_error",
"test/test_errors.py::test_import_error",
"test/test_errors.py::test_malformed_process",
"test/test_errors.py::test_process_import_error",
"test/test_errors.py::test_syntax_error",
"test/test_errors.py::test_process_exception",
"test/test_errors.py::test_output_error",
"test/test_errors.py::test_finished_task",
"test/test_errors.py::test_strip_zoom_error",
"test/test_executor.py::test_sequential_executor_as_completed",
"test/test_executor.py::test_sequential_executor_as_completed_skip",
"test/test_executor.py::test_sequential_executor_map",
"test/test_executor.py::test_concurrent_futures_processes_executor_as_completed",
"test/test_executor.py::test_concurrent_futures_processes_executor_as_completed_max_tasks",
"test/test_executor.py::test_concurrent_futures_processes_executor_as_completed_skip",
"test/test_executor.py::test_concurrent_futures_processes_executor_cancel_as_completed",
"test/test_executor.py::test_concurrent_futures_processes_executor_map",
"test/test_executor.py::test_concurrent_futures_threads_executor_as_completed",
"test/test_executor.py::test_concurrent_futures_threads_executor_as_completed_skip",
"test/test_executor.py::test_concurrent_futures_threads_executor_map",
"test/test_executor.py::test_fake_future",
"test/test_executor.py::test_process_exception_tile",
"test/test_executor.py::test_process_exception_zoom"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-06-02 15:27:48+00:00 | mit | 6,163 |
|
unified-font-object__ufoNormalizer-72 | diff --git a/src/ufonormalizer.py b/src/ufonormalizer.py
index ff76f91..796bb37 100644
--- a/src/ufonormalizer.py
+++ b/src/ufonormalizer.py
@@ -4,6 +4,7 @@ from __future__ import print_function, unicode_literals
import time
import os
+import re
import shutil
from xml.etree import cElementTree as ET
import plistlib
@@ -158,11 +159,9 @@ else:
class UFONormalizerError(Exception):
pass
-
DEFAULT_FLOAT_PRECISION = 10
FLOAT_FORMAT = "%%.%df" % DEFAULT_FLOAT_PRECISION
-
def normalizeUFO(ufoPath, outputPath=None, onlyModified=True,
floatPrecision=DEFAULT_FLOAT_PRECISION, writeModTimes=True):
global FLOAT_FORMAT
@@ -1178,6 +1177,8 @@ class XMLWriter(object):
self.raw(line)
def text(self, text):
+ text = text.strip("\n")
+ text = dedent_tabs(text)
text = text.strip()
text = xmlEscapeText(text)
paragraphs = []
@@ -1358,6 +1359,64 @@ def xmlConvertFloat(value):
def xmlConvertInt(value):
return str(value)
+
+# ---------------
+# Text Operations
+# ---------------
+
+WHITESPACE_ONLY_RE = re.compile('^[\s\t]+$', re.MULTILINE)
+LEADING_WHITESPACE_RE = re.compile('(^(?:\s{4}|\t)*)(?:[^\t\n])', re.MULTILINE)
+
+def dedent_tabs(text):
+ """
+ Based on `textwrap.dedent`, but modified to only work on tabs and 4-space indents
+
+ Remove any common leading tabs from every line in `text`.
+ This can be used to make triple-quoted strings line up with the left
+ edge of the display, while still presenting them in the source code
+ in indented form.
+
+ Entirely blank lines are normalized to a newline character.
+ """
+ # Look for the longest leading string of spaces and tabs common to
+ # all lines.
+ margin = None
+ text = WHITESPACE_ONLY_RE.sub('', text)
+ indents = LEADING_WHITESPACE_RE.findall(text)
+ for indent in indents:
+ if margin is None:
+ margin = indent
+
+ # Current line more deeply indented than previous winner:
+ # no change (previous winner is still on top).
+ elif indent.startswith(margin):
+ pass
+
+ # Current line consistent with and no deeper than previous winner:
+ # it's the new winner.
+ elif margin.startswith(indent):
+ margin = indent
+
+ # Find the largest common whitespace between current line and previous
+ # winner.
+ else:
+ for i, (x, y) in enumerate(zip(margin, indent)):
+ if x != y:
+ margin = margin[:i]
+ break
+
+ # sanity check (testing/debugging only)
+ if 0 and margin:
+ for line in text.split("\n"):
+ assert not line or line.startswith(margin), \
+ "line = %r, margin = %r" % (line, margin)
+
+ if margin:
+ text = re.sub(r'(?m)^' + margin, '', text)
+ return text
+
+
+
# ---------------
# Path Operations
# ---------------
| unified-font-object/ufoNormalizer | 5b67c7aa760ef66748badc5f208a7d1aab9a0c69 | diff --git a/tests/test_ufonormalizer.py b/tests/test_ufonormalizer.py
index 910d5ae..cde30e0 100644
--- a/tests/test_ufonormalizer.py
+++ b/tests/test_ufonormalizer.py
@@ -836,6 +836,53 @@ class UFONormalizerTest(unittest.TestCase):
writer.getText(),
"<note>\n\tLine1\n\t\n\t Line3\n</note>")
+ # Normalizer should not indent Line2 and Line3 more than already indented
+ element = ET.fromstring(
+ "<note>\n\tLine1\n\tLine2\n\tLine3\n</note>")
+ writer = XMLWriter(declaration=None)
+ _normalizeGlifNote(element, writer)
+ self.assertEqual(
+ writer.getText(),
+ "<note>\n\tLine1\n\tLine2\n\tLine3\n</note>")
+
+ # Normalizer should keep the extra tab in line 2
+ element = ET.fromstring(
+ "<note>\n\tLine1\n\t\tLine2\n\tLine3\n</note>")
+ writer = XMLWriter(declaration=None)
+ _normalizeGlifNote(element, writer)
+ self.assertEqual(
+ writer.getText(),
+ "<note>\n\tLine1\n\t\tLine2\n\tLine3\n</note>")
+
+ # Normalizer should keep the extra spaces on line 2
+ element = ET.fromstring(
+ "<note>\n\tLine1\n\t Line2\n\tLine3\n</note>")
+ writer = XMLWriter(declaration=None)
+ _normalizeGlifNote(element, writer)
+ self.assertEqual(
+ writer.getText(),
+ "<note>\n\tLine1\n\t Line2\n\tLine3\n</note>")
+
+ # Normalizer should remove the extra tab all lines have in common,
+ # but leave the additional tab on line 2
+ element = ET.fromstring(
+ "<note>\n\t\tLine1\n\t\t\tLine2\n\t\tLine3\n</note>")
+ writer = XMLWriter(declaration=None)
+ _normalizeGlifNote(element, writer)
+ self.assertEqual(
+ writer.getText(),
+ "<note>\n\tLine1\n\t\tLine2\n\tLine3\n</note>")
+
+ # Normalizer should remove the extra 4-space all lines have in common,
+ # but leave the additional 4-space on line 2
+ element = ET.fromstring(
+ "<note>\n Line1\n Line2\n Line3\n</note>")
+ writer = XMLWriter(declaration=None)
+ _normalizeGlifNote(element, writer)
+ self.assertEqual(
+ writer.getText(),
+ "<note>\n\tLine1\n\t Line2\n\tLine3\n</note>")
+
def test_normalizeGLIF_note_undefined(self):
element = ET.fromstring("<note></note>")
writer = XMLWriter(declaration=None)
| Trouble normalizing the indention of new lines in Glyph Notes
Hi,
We've been noticing that if a glyph has line returns in a note, the Normalizer has some trouble formatting it.
For instance, here is how a note started out after it was added, and its first Normalization:
```xml
<note>
Line1
Line2
</note>
```
and with each round of normalization, all the lines after the first get indented an extra level
Once:
```xml
<note>
Line1
Line2
</note>
```
Twice:
```xml
<note>
Line1
Line2
</note>
```
Thrice:
```xml
<note>
Line1
Line2
</note>
```
etc. | 0.0 | 5b67c7aa760ef66748badc5f208a7d1aab9a0c69 | [
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_note_defined"
]
| [
"tests/test_ufonormalizer.py::UFONormalizerErrorTest::test_str",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_main_input_does_not_exist",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_main_input_not_ufo",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_main_invalid_float_precision",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_main_no_metainfo_plist",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_main_no_path",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_main_verbose_or_quiet",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_horizontal_x_is_zero",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_invalid_angle",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_invalid_x",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_invalid_y",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_no_angle",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_no_color",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_no_identifier",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_no_name",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_no_x",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_no_y",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_vertical_y_is_zero",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_guidelines_zero_is_not_None",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeFontInfoPlist_no_guidelines",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_advance_defaults",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_advance_height",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_advance_invalid_values",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_advance_undefined",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_advance_width",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_anchor_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_anchor_no_color",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_anchor_no_identifier",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_anchor_no_name",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_anchor_no_x",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_anchor_no_y",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_formats_1_and_2",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_guideline_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_guideline_invalid",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_image_empty",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_image_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_image_no_color",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_image_no_file_name",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_image_no_transformation",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_lib_undefined",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_no_formats",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_note_undefined",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_outline_format1_element_order",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_outline_format1_empty",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_unicode_with_hex",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGLIF_unicode_without_hex",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_component_attributes_format1_defaults",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_component_attributes_format1_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_component_attributes_format1_no_base",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_component_attributes_format1_no_transformation",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_component_attributes_format2_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_component_format1_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_component_format1_no_base",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_component_format1_subelement",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format1_empty",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format1_implied_anchor",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format1_implied_anchor_with_empty_name",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format1_implied_anchor_without_name",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format1_normal",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format1_point_without_attributes",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format1_unkown_child_element",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format1_unkown_point_type",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format2_empty",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format2_normal",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format2_point_without_attributes",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_contour_format2_unknown_child_element",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_outline_format2_element_order",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_outline_format2_empty",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_empty_name",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_invalid_x",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_invalid_y",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_no_name",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_no_x",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_no_y",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_subelement",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format1_type_and_smooth",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_point_attributes_format2_everything",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_transformation_default",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_transformation_empty",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_transformation_invalid_value",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_transformation_non_default",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeGlif_transformation_unknown_attribute",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalizeLayerInfoPlist_color",
"tests/test_ufonormalizer.py::UFONormalizerTest::test_normalize_color_string",
"tests/test_ufonormalizer.py::XMLWriterTest::test_attributesToString",
"tests/test_ufonormalizer.py::XMLWriterTest::test_propertyListObject_array",
"tests/test_ufonormalizer.py::XMLWriterTest::test_propertyListObject_boolean",
"tests/test_ufonormalizer.py::XMLWriterTest::test_propertyListObject_dict",
"tests/test_ufonormalizer.py::XMLWriterTest::test_propertyListObject_float",
"tests/test_ufonormalizer.py::XMLWriterTest::test_propertyListObject_integer",
"tests/test_ufonormalizer.py::XMLWriterTest::test_propertyListObject_none",
"tests/test_ufonormalizer.py::XMLWriterTest::test_propertyListObject_string",
"tests/test_ufonormalizer.py::XMLWriterTest::test_xmlConvertFloat",
"tests/test_ufonormalizer.py::XMLWriterTest::test_xmlConvertFloat_custom_precision",
"tests/test_ufonormalizer.py::XMLWriterTest::test_xmlConvertFloat_no_rounding",
"tests/test_ufonormalizer.py::XMLWriterTest::test_xmlConvertInt",
"tests/test_ufonormalizer.py::XMLWriterTest::test_xmlConvertValue",
"tests/test_ufonormalizer.py::XMLWriterTest::test_xmlEscapeAttribute",
"tests/test_ufonormalizer.py::XMLWriterTest::test_xmlEscapeText",
"tests/test_ufonormalizer.py::SubpathTest::test_readModTimes",
"tests/test_ufonormalizer.py::SubpathTest::test_storeModTimes",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathExists",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathGetModTime",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathJoin",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathNeedsRefresh",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathReadFile",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathRemoveFile",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathRenameDirectory",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathRenameFile",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathSplit",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathWriteFile",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathWriteFile_newline",
"tests/test_ufonormalizer.py::SubpathTest::test_subpathWritePlist",
"tests/test_ufonormalizer.py::NameTranslationTest::test_handleClash1",
"tests/test_ufonormalizer.py::NameTranslationTest::test_handleClash1_max_file_length",
"tests/test_ufonormalizer.py::NameTranslationTest::test_handleClash2",
"tests/test_ufonormalizer.py::NameTranslationTest::test_userNameToFileName"
]
| {
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2020-07-08 16:44:19+00:00 | bsd-3-clause | 6,164 |
|
unit8co__darts-1435 | diff --git a/darts/timeseries.py b/darts/timeseries.py
index fc757f58..b629aa4f 100644
--- a/darts/timeseries.py
+++ b/darts/timeseries.py
@@ -2604,10 +2604,6 @@ class TimeSeries:
attrs=self._xa.attrs,
)
- # new_xa = xr.concat(objs=[self._xa, other_xa], dim=str(self._time_dim))
- if not self._has_datetime_index:
- new_xa = new_xa.reset_index(dims_or_levels=new_xa.dims[0])
-
return self.__class__.from_xarray(
new_xa, fill_missing_dates=True, freq=self._freq_str
)
@@ -2626,7 +2622,6 @@ class TimeSeries:
TimeSeries
A new TimeSeries with the new values appended
"""
-
if self._has_datetime_index:
idx = pd.DatetimeIndex(
[self.end_time() + i * self._freq for i in range(1, len(values) + 1)],
@@ -2634,9 +2629,10 @@ class TimeSeries:
)
else:
idx = pd.RangeIndex(
- len(self), len(self) + self.freq * len(values), step=self.freq
+ start=self.end_time() + self._freq,
+ stop=self.end_time() + (len(values) + 1) * self._freq,
+ step=self._freq,
)
-
return self.append(
self.__class__.from_times_and_values(
values=values,
| unit8co/darts | 9a40ca61ad34a7087bcfb27b01f0ea845a9fa4ae | diff --git a/darts/tests/test_timeseries.py b/darts/tests/test_timeseries.py
index c4414a13..61688bd2 100644
--- a/darts/tests/test_timeseries.py
+++ b/darts/tests/test_timeseries.py
@@ -621,15 +621,53 @@ class TimeSeriesTestCase(DartsBaseTestClass):
def test_append(self):
TimeSeriesTestCase.helper_test_append(self, self.series1)
+ # Check `append` deals with `RangeIndex` series correctly:
+ series_1 = linear_timeseries(start=1, length=5, freq=2)
+ series_2 = linear_timeseries(start=11, length=2, freq=2)
+ appended = series_1.append(series_2)
+ expected_vals = np.concatenate(
+ [series_1.all_values(), series_2.all_values()], axis=0
+ )
+ expected_idx = pd.RangeIndex(start=1, stop=15, step=2)
+ self.assertTrue(np.allclose(appended.all_values(), expected_vals))
+ self.assertTrue(appended.time_index.equals(expected_idx))
def test_append_values(self):
TimeSeriesTestCase.helper_test_append_values(self, self.series1)
+ # Check `append_values` deals with `RangeIndex` series correctly:
+ series = linear_timeseries(start=1, length=5, freq=2)
+ appended = series.append_values(np.ones((2, 1, 1)))
+ expected_vals = np.concatenate(
+ [series.all_values(), np.ones((2, 1, 1))], axis=0
+ )
+ expected_idx = pd.RangeIndex(start=1, stop=15, step=2)
+ self.assertTrue(np.allclose(appended.all_values(), expected_vals))
+ self.assertTrue(appended.time_index.equals(expected_idx))
def test_prepend(self):
TimeSeriesTestCase.helper_test_prepend(self, self.series1)
+ # Check `prepend` deals with `RangeIndex` series correctly:
+ series_1 = linear_timeseries(start=1, length=5, freq=2)
+ series_2 = linear_timeseries(start=11, length=2, freq=2)
+ prepended = series_2.prepend(series_1)
+ expected_vals = np.concatenate(
+ [series_1.all_values(), series_2.all_values()], axis=0
+ )
+ expected_idx = pd.RangeIndex(start=1, stop=15, step=2)
+ self.assertTrue(np.allclose(prepended.all_values(), expected_vals))
+ self.assertTrue(prepended.time_index.equals(expected_idx))
def test_prepend_values(self):
TimeSeriesTestCase.helper_test_prepend_values(self, self.series1)
+ # Check `prepend_values` deals with `RangeIndex` series correctly:
+ series = linear_timeseries(start=1, length=5, freq=2)
+ prepended = series.prepend_values(np.ones((2, 1, 1)))
+ expected_vals = np.concatenate(
+ [np.ones((2, 1, 1)), series.all_values()], axis=0
+ )
+ expected_idx = pd.RangeIndex(start=-3, stop=11, step=2)
+ self.assertTrue(np.allclose(prepended.all_values(), expected_vals))
+ self.assertTrue(prepended.time_index.equals(expected_idx))
def test_with_values(self):
vals = np.random.rand(5, 10, 3)
| [BUG] `append_values` incorrectly extends `time_index` of `pd.RangeIndex`-typed `TimeSeries`
**Describe the bug**
When `append_values` is used to add new values to a `pd.RangeIndex`-typed `TimeSeries` , the `time_index` of the entire series is 'reset' so that each value is labeled with its index position. This is particularly unexpected if the `TimeSeries` in question does not have a frequency of `1` and/or does not start with a `time_index` of `0`.
**To Reproduce**
Consider the following example:
```python
from darts.utils.timeseries_generation import linear_timeseries
import numpy as np
series = linear_timeseries(start=1, length=5, freq=2)
print('Before `append_values`:')
print(list(series.time_index))
new_values = np.ones((1,))
print('After `append_values`:')
print(list(series.append_values(new_values).time_index))
```
This yields:
```
Before `append_values`:
[1, 3, 5, 7, 9]
After `append_values`:
[0, 1, 2, 3, 4, 5]
```
Notice how the `time_index` now starts at `0` instead of `1` **and** has a frequency of `1` instead of `2`.
**Expected behavior**
Instead of resetting the `time_index` of `pd.RangeIndex`-typed `TimeSeries`, `append_values` should 'extend' the `time_index`. More explicitly, for the previous example, one should expect the output:
```
Before `append_values`:
[1, 3, 5, 7, 9]
After `append_values`:
[1, 3, 5, 7, 9, 11]
```
Indeed, this is the [behaviour that's advertised by `append_values`' docstring](https://unit8co.github.io/darts/generated_api/darts.timeseries.html#darts.timeseries.TimeSeries.append_values) and, additionally, is how it behaves when dealing with `pd.DatetimeIndex`-typed `TimeSeries`. To see this, consider the following example:
```python
from darts.utils.timeseries_generation import linear_timeseries
import numpy as np
import pandas as pd
series = linear_timeseries(start=pd.Timestamp('1/1/2000'), length=2, freq='2d')
print('Before `append_values`:')
print(list(series.time_index))
new_values = np.ones((1,))
print('After `append_values`:')
print(list(series.append_values(new_values).time_index))
```
This prints:
```
Before `append_values`:
[Timestamp('2000-01-01 00:00:00', freq='2D'), Timestamp('2000-01-03 00:00:00', freq='2D')]
After `append_values`:
[Timestamp('2000-01-01 00:00:00', freq='2D'), Timestamp('2000-01-03 00:00:00', freq='2D'), Timestamp('2000-01-05 00:00:00', freq='2D')]
```
Notice how the `append_values` has simply added the date `2000-01-05` to the `time_index` of `series`.
In cases where the user really wants 'reset' the `time_index` of a `TimeSeries` after appending values, this should probably be achieved by implementing a separate `TimeSeries.reset_index()` method.
**System (please complete the following information):**
- Python version: 3.10.6
- darts version: 0.22.0
**Additional context**
N/A | 0.0 | 9a40ca61ad34a7087bcfb27b01f0ea845a9fa4ae | [
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_append",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_append_values",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_prepend",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_prepend_values"
]
| [
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_alt_creation",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_column_names",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_creation",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_dates",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_diff",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_drop",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_eq",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_fill_missing_dates",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_fillna_value",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_from_csv",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_gaps",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_getitem",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_index_creation",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_integer_indexing",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_intersect",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_longest_contiguous_slice",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_map",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_map_with_timestamp",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_map_wrong_fn",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_ops",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_quantiles",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_quantiles_df",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_rescale",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_shift",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_short_series_slice",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_slice",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_split",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_to_csv_deterministic",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_to_csv_probabilistic_ts",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_to_csv_stochastic",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_univariate_component",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_with_columns_renamed",
"darts/tests/test_timeseries.py::TimeSeriesTestCase::test_with_values",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_component_different_time_axes_no_force",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_component_different_time_axes_with_force",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_component_different_time_axes_with_force_uneven_series",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_component_sunny_day",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_sample_sunny_day",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_time_different_time_axes_force",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_time_different_time_axes_no_force",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_time_different_time_axes_no_force_2_day_freq",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_time_same_time_force",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_time_same_time_no_force",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_time_sunny_day",
"darts/tests/test_timeseries.py::TimeSeriesConcatenateTestCase::test_concatenate_timeseries_method",
"darts/tests/test_timeseries.py::TimeSeriesHierarchyTestCase::test_concat",
"darts/tests/test_timeseries.py::TimeSeriesHierarchyTestCase::test_creation_with_hierarchy_sunny_day",
"darts/tests/test_timeseries.py::TimeSeriesHierarchyTestCase::test_hierarchy_processing",
"darts/tests/test_timeseries.py::TimeSeriesHierarchyTestCase::test_ops",
"darts/tests/test_timeseries.py::TimeSeriesHierarchyTestCase::test_with_hierarchy_rainy_day",
"darts/tests/test_timeseries.py::TimeSeriesHierarchyTestCase::test_with_hierarchy_sunny_day",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_head_numeric_time_index",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_head_overshot_component_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_head_overshot_sample_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_head_overshot_time_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_head_sunny_day_component_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_head_sunny_day_sample_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_head_sunny_day_time_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_tail_numeric_time_index",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_tail_overshot_component_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_tail_overshot_sample_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_tail_overshot_time_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_tail_sunny_day_component_axis",
"darts/tests/test_timeseries.py::TimeSeriesHeadTailTestCase::test_tail_sunny_day_time_axis",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_fail_with_bad_integer_time_col",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_from_dataframe_sunny_day",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_time_col_convert_datetime",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_time_col_convert_datetime_strings",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_time_col_convert_garbage",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_time_col_convert_integers",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_time_col_convert_rangeindex",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_time_col_convert_string_integers",
"darts/tests/test_timeseries.py::TimeSeriesFromDataFrameTestCase::test_time_col_with_tz",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_kurtosis",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_max",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_mean",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_median",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_min",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_quantile",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_skew",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_std",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_sum",
"darts/tests/test_timeseries.py::SimpleStatisticsTestCase::test_var"
]
| {
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-12-18 03:42:10+00:00 | apache-2.0 | 6,165 |
|
unit8co__darts-2152 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45fa2eb6..fa602543 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,8 @@ but cannot always guarantee backwards compatibility. Changes that may **break co
### For users of the library:
**Improved**
+- Improvements to `TimeSeries`:
+ - Improved the time series frequency inference when using slices or pandas DatetimeIndex as keys for `__getitem__`. [#2152](https://github.com/unit8co/darts/pull/2152) by [DavidKleindienst](https://github.com/DavidKleindienst).
**Fixed**
- Fixed a bug when using a `TorchForecastingModel` with `use_reversible_instance_norm=True` and predicting with `n > output_chunk_length`. The input normalized multiple times. [#2160](https://github.com/unit8co/darts/pull/2160) by [FourierMourier](https://github.com/FourierMourier).
diff --git a/darts/timeseries.py b/darts/timeseries.py
index 1792dfe3..0a715d10 100644
--- a/darts/timeseries.py
+++ b/darts/timeseries.py
@@ -4899,12 +4899,13 @@ class TimeSeries:
logger,
)
- def _set_freq_in_xa(xa_: xr.DataArray):
+ def _set_freq_in_xa(xa_: xr.DataArray, freq=None):
# mutates the DataArray to make sure it contains the freq
if isinstance(xa_.get_index(self._time_dim), pd.DatetimeIndex):
- inferred_freq = xa_.get_index(self._time_dim).inferred_freq
- if inferred_freq is not None:
- xa_.get_index(self._time_dim).freq = to_offset(inferred_freq)
+ if freq is None:
+ freq = xa_.get_index(self._time_dim).inferred_freq
+ if freq is not None:
+ xa_.get_index(self._time_dim).freq = to_offset(freq)
else:
xa_.get_index(self._time_dim).freq = self._freq
@@ -4920,8 +4921,9 @@ class TimeSeries:
xa_ = self._xa.sel({self._time_dim: key})
# indexing may discard the freq so we restore it...
- # TODO: unit-test this
- _set_freq_in_xa(xa_)
+ # if the DateTimeIndex already has an associated freq, use it
+ # otherwise key.freq is None and the freq will be inferred
+ _set_freq_in_xa(xa_, key.freq)
return self.__class__(xa_)
elif isinstance(key, pd.RangeIndex):
@@ -4951,18 +4953,43 @@ class TimeSeries:
key.stop, (int, np.int64)
):
xa_ = self._xa.isel({self._time_dim: key})
- _set_freq_in_xa(
- xa_
- ) # indexing may discard the freq so we restore it...
+ if isinstance(key.step, (int, np.int64)):
+ # new frequency is multiple of original
+ new_freq = key.step * self.freq
+ elif key.step is None:
+ new_freq = self.freq
+ else:
+ new_freq = None
+ raise_log(
+ ValueError(
+ f"Invalid slice step={key.step}. Only supports integer steps or `None`."
+ ),
+ logger=logger,
+ )
+ # indexing may discard the freq so we restore it...
+ _set_freq_in_xa(xa_, new_freq)
return self.__class__(xa_)
elif isinstance(key.start, pd.Timestamp) or isinstance(
key.stop, pd.Timestamp
):
_check_dt()
+ if isinstance(key.step, (int, np.int64)):
+ # new frequency is multiple of original
+ new_freq = key.step * self.freq
+ elif key.step is None:
+ new_freq = self.freq
+ else:
+ new_freq = None
+ raise_log(
+ ValueError(
+ f"Invalid slice step={key.step}. Only supports integer steps or `None`."
+ ),
+ logger=logger,
+ )
# indexing may discard the freq so we restore it...
xa_ = self._xa.sel({self._time_dim: key})
- _set_freq_in_xa(xa_)
+ _set_freq_in_xa(xa_, new_freq)
return self.__class__(xa_)
# handle simple types:
@@ -5030,13 +5057,18 @@ class TimeSeries:
# We have to restore a RangeIndex. But first we need to
# check the list is corresponding to a RangeIndex.
min_idx, max_idx = min(key), max(key)
- raise_if_not(
- key[0] == min_idx
+ if (
+ not key[0] == min_idx
and key[-1] == max_idx
- and max_idx + 1 - min_idx == len(key),
- "Indexing a TimeSeries with a list requires the list to contain monotically "
- + "increasing integers with no gap.",
- )
+ and max_idx + 1 - min_idx == len(key)
+ ):
+ raise_log(
+ ValueError(
+ "Indexing a TimeSeries with a list requires the list to "
+ "contain monotonically increasing integers with no gap."
+ ),
+ logger=logger,
+ )
new_idx = orig_idx[min_idx : max_idx + 1]
xa_ = xa_.assign_coords({self._time_dim: new_idx})
| unit8co/darts | de4afd1290933907f7f1d29482507cf88d4ce69b | diff --git a/darts/tests/test_timeseries.py b/darts/tests/test_timeseries.py
index db5459fe..2a2b7c27 100644
--- a/darts/tests/test_timeseries.py
+++ b/darts/tests/test_timeseries.py
@@ -17,7 +17,6 @@ from darts.utils.timeseries_generation import (
class TestTimeSeries:
-
times = pd.date_range("20130101", "20130110", freq="D")
pd_series1 = pd.Series(range(10), index=times)
pd_series2 = pd.Series(range(5, 15), index=times)
@@ -933,6 +932,55 @@ class TestTimeSeries:
with pytest.raises(KeyError):
_ = series[pd.RangeIndex(start, stop=end + 2 * freq, step=freq)]
+ def test_getitem_frequency_inferrence(self):
+ ts = self.series1
+ assert ts.freq == "D"
+ ts_got = ts[1::2]
+ assert ts_got.freq == "2D"
+ ts_got = ts[pd.Timestamp("20130103") :: 2]
+ assert ts_got.freq == "2D"
+
+ idx = pd.DatetimeIndex(["20130102", "20130105", "20130108"])
+ ts_idx = ts[idx]
+ assert ts_idx.freq == "3D"
+
+ # With BusinessDay frequency
+ offset = pd.offsets.BusinessDay() # Closed on Saturdays & Sundays
+ dates1 = pd.date_range("20231101", "20231126", freq=offset)
+ values1 = np.ones(len(dates1))
+ ts = TimeSeries.from_times_and_values(dates1, values1)
+ assert ts.freq == ts[-4:].freq
+
+ # Using a step parameter
+ assert ts[1::3].freq == 3 * ts.freq
+ assert ts[pd.Timestamp("20231102") :: 4].freq == 4 * ts.freq
+
+ # Indexing with datetime index
+ idx = pd.date_range("20231101", "20231126", freq=offset)
+ assert ts[idx].freq == idx.freq
+
+ def test_getitem_frequency_inferrence_integer_index(self):
+ start = 2
+ freq = 3
+ ts = TimeSeries.from_times_and_values(
+ times=pd.RangeIndex(
+ start=start, stop=start + freq * len(self.series1), step=freq
+ ),
+ values=self.series1.values(),
+ )
+
+ assert ts.freq == freq
+ ts_got = ts[1::2]
+ assert ts_got.start_time() == start + freq
+ assert ts_got.freq == 2 * freq
+
+ idx = pd.RangeIndex(
+ start=start + 2 * freq, stop=start + 4 * freq, step=2 * freq
+ )
+ ts_idx = ts[idx]
+ assert ts_idx.start_time() == idx[0]
+ assert ts_idx.freq == 2 * freq
+
def test_fill_missing_dates(self):
with pytest.raises(ValueError):
# Series cannot have date holes without automatic filling
@@ -1050,7 +1098,6 @@ class TestTimeSeries:
series_target = TimeSeries.from_dataframe(df_full, time_col="date")
for df, df_name in zip([df_full, df_holes], ["full", "holes"]):
-
# fill_missing_dates will find multiple inferred frequencies (i.e. for 'B' it finds {'B', 'D'})
if offset_alias in offset_aliases_raise:
with pytest.raises(ValueError):
@@ -1519,7 +1566,6 @@ class TestTimeSeries:
class TestTimeSeriesConcatenate:
-
#
# COMPONENT AXIS TESTS
#
@@ -1735,7 +1781,6 @@ class TestTimeSeriesConcatenate:
class TestTimeSeriesHierarchy:
-
components = ["total", "a", "b", "x", "y", "ax", "ay", "bx", "by"]
hierarchy = {
@@ -1912,7 +1957,6 @@ class TestTimeSeriesHierarchy:
class TestTimeSeriesHeadTail:
-
ts = TimeSeries(
xr.DataArray(
np.random.rand(10, 10, 10),
@@ -2185,7 +2229,6 @@ class TestTimeSeriesFromDataFrame:
class TestSimpleStatistics:
-
times = pd.date_range("20130101", "20130110", freq="D")
values = np.random.rand(10, 2, 100)
ar = xr.DataArray(
| [BUG] TimeSeries slicing silently changes the TimeSeries' frequency
**Describe the bug**
When using BusinessDay as frequency, selecting a slice e.g. ts[1:5] can result in the slice having a different frequency (Day).
This is problematic because subsequent concatenations can fail because the two TimeSeries won't be contiguous at the altered frequency (but would be contiguous at the original frequency)
**To Reproduce**
```python
from darts import TimeSeries, concatenate
import pandas as pd
import numpy as np
offset = pd.offsets.BusinessDay() # Closed on Saturdays & Sundays
dates1 = pd.date_range("2023-11-01","2023-11-26", freq=offset) # the 26th is a sunday, last date is the 24th
values1 = np.ones(len(dates1))
ts1 = TimeSeries.from_times_and_values(dates1,values1)
dates2 = pd.date_range("2023-11-26","2023-12-06", freq=offset) # First date is the 27th
values2 = np.ones(len(dates2))
ts2 = TimeSeries.from_times_and_values(dates2, values2)
concatenate((ts1,ts2)) # works
print(ts1.freq) # <BusinessDay>
ts_subset = ts1[-4:]
print(ts_subset.freq) # <Day>
concatenate((ts_subset, ts2)) # Fails
````
**Expected behavior**
TimeSeries slicing should not silently alter the frequency
**System (please complete the following information):**
- Python version: 3.10
- darts version: Tested on master and 0.25
| 0.0 | de4afd1290933907f7f1d29482507cf88d4ce69b | [
"darts/tests/test_timeseries.py::TestTimeSeries::test_getitem_frequency_inferrence"
]
| [
"darts/tests/test_timeseries.py::TestTimeSeries::test_creation",
"darts/tests/test_timeseries.py::TestTimeSeries::test_pandas_creation",
"darts/tests/test_timeseries.py::TestTimeSeries::test_integer_range_indexing",
"darts/tests/test_timeseries.py::TestTimeSeries::test_integer_indexing",
"darts/tests/test_timeseries.py::TestTimeSeries::test_datetime_indexing",
"darts/tests/test_timeseries.py::TestTimeSeries::test_univariate_component",
"darts/tests/test_timeseries.py::TestTimeSeries::test_column_names",
"darts/tests/test_timeseries.py::TestTimeSeries::test_quantiles",
"darts/tests/test_timeseries.py::TestTimeSeries::test_quantiles_df",
"darts/tests/test_timeseries.py::TestTimeSeries::test_alt_creation",
"darts/tests/test_timeseries.py::TestTimeSeries::test_eq",
"darts/tests/test_timeseries.py::TestTimeSeries::test_dates",
"darts/tests/test_timeseries.py::TestTimeSeries::test_rescale",
"darts/tests/test_timeseries.py::TestTimeSeries::test_slice",
"darts/tests/test_timeseries.py::TestTimeSeries::test_split",
"darts/tests/test_timeseries.py::TestTimeSeries::test_drop",
"darts/tests/test_timeseries.py::TestTimeSeries::test_intersect",
"darts/tests/test_timeseries.py::TestTimeSeries::test_shift",
"darts/tests/test_timeseries.py::TestTimeSeries::test_append",
"darts/tests/test_timeseries.py::TestTimeSeries::test_append_values",
"darts/tests/test_timeseries.py::TestTimeSeries::test_prepend",
"darts/tests/test_timeseries.py::TestTimeSeries::test_prepend_values",
"darts/tests/test_timeseries.py::TestTimeSeries::test_with_values",
"darts/tests/test_timeseries.py::TestTimeSeries::test_cumsum",
"darts/tests/test_timeseries.py::TestTimeSeries::test_diff",
"darts/tests/test_timeseries.py::TestTimeSeries::test_ops",
"darts/tests/test_timeseries.py::TestTimeSeries::test_getitem_datetime_index",
"darts/tests/test_timeseries.py::TestTimeSeries::test_getitem_integer_index",
"darts/tests/test_timeseries.py::TestTimeSeries::test_getitem_frequency_inferrence_integer_index",
"darts/tests/test_timeseries.py::TestTimeSeries::test_fill_missing_dates",
"darts/tests/test_timeseries.py::TestTimeSeries::test_fillna_value",
"darts/tests/test_timeseries.py::TestTimeSeries::test_short_series_creation",
"darts/tests/test_timeseries.py::TestTimeSeries::test_from_csv",
"darts/tests/test_timeseries.py::TestTimeSeries::test_index_creation",
"darts/tests/test_timeseries.py::TestTimeSeries::test_short_series_slice",
"darts/tests/test_timeseries.py::TestTimeSeries::test_map",
"darts/tests/test_timeseries.py::TestTimeSeries::test_map_with_timestamp",
"darts/tests/test_timeseries.py::TestTimeSeries::test_map_wrong_fn",
"darts/tests/test_timeseries.py::TestTimeSeries::test_gaps",
"darts/tests/test_timeseries.py::TestTimeSeries::test_longest_contiguous_slice",
"darts/tests/test_timeseries.py::TestTimeSeries::test_with_columns_renamed",
"darts/tests/test_timeseries.py::TestTimeSeries::test_to_csv_probabilistic_ts",
"darts/tests/test_timeseries.py::TestTimeSeries::test_to_csv_deterministic",
"darts/tests/test_timeseries.py::TestTimeSeries::test_to_csv_stochastic",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_component_sunny_day",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_component_different_time_axes_no_force",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_component_different_time_axes_with_force",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_component_different_time_axes_with_force_uneven_series",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_sample_sunny_day",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_time_sunny_day",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_time_same_time_no_force",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_time_same_time_force",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_time_different_time_axes_no_force",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_time_different_time_axes_force",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_time_different_time_axes_no_force_2_day_freq",
"darts/tests/test_timeseries.py::TestTimeSeriesConcatenate::test_concatenate_timeseries_method",
"darts/tests/test_timeseries.py::TestTimeSeriesHierarchy::test_creation_with_hierarchy_sunny_day",
"darts/tests/test_timeseries.py::TestTimeSeriesHierarchy::test_with_hierarchy_sunny_day",
"darts/tests/test_timeseries.py::TestTimeSeriesHierarchy::test_with_hierarchy_rainy_day",
"darts/tests/test_timeseries.py::TestTimeSeriesHierarchy::test_hierarchy_processing",
"darts/tests/test_timeseries.py::TestTimeSeriesHierarchy::test_concat",
"darts/tests/test_timeseries.py::TestTimeSeriesHierarchy::test_ops",
"darts/tests/test_timeseries.py::TestTimeSeriesHierarchy::test_with_string_items",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_head_sunny_day_time_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_head_sunny_day_component_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_tail_sunny_day_time_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_tail_sunny_day_component_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_head_sunny_day_sample_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_head_overshot_time_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_head_overshot_component_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_head_overshot_sample_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_head_numeric_time_index",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_tail_overshot_time_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_tail_overshot_component_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_tail_overshot_sample_axis",
"darts/tests/test_timeseries.py::TestTimeSeriesHeadTail::test_tail_numeric_time_index",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_from_dataframe_sunny_day",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_time_col_convert_string_integers",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_time_col_convert_integers",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_fail_with_bad_integer_time_col",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_time_col_convert_rangeindex",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_time_col_convert_datetime",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_time_col_convert_datetime_strings",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_time_col_with_tz",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_time_col_convert_garbage",
"darts/tests/test_timeseries.py::TestTimeSeriesFromDataFrame::test_df_named_columns_index",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_mean",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_var",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_std",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_skew",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_kurtosis",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_min",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_max",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_sum",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_median",
"darts/tests/test_timeseries.py::TestSimpleStatistics::test_quantile"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2024-01-10 09:13:10+00:00 | apache-2.0 | 6,166 |
|
unnonouno__mrep-26 | diff --git a/.travis.yml b/.travis.yml
index 177de39..9c1021f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,6 +7,7 @@ python:
- "3.4"
install:
+ - pip install coverage==3.7.1
- pip install tornado
- pip install coveralls
- wget https://mecab.googlecode.com/files/mecab-0.996.tar.gz
diff --git a/README.rst b/README.rst
index 1715f6f..d3f9e93 100644
--- a/README.rst
+++ b/README.rst
@@ -68,6 +68,12 @@ Pattern
`<pos=XXX>`
matches morphemes whose POS are `XXX`
+`<feature=XXX>`
+ matches morphemes whose features are `XXX`
+
+`<feature=~XXX>`
+ matches morphemes whose features maches a RegExp pattern `XXX`
+
`X*`
matches repetiion of a pattern X
diff --git a/mrep/builder.py b/mrep/builder.py
index afc189d..627563f 100644
--- a/mrep/builder.py
+++ b/mrep/builder.py
@@ -96,13 +96,22 @@ def term(s, pos):
p = consume(s, p, ')')
return (p, t)
elif c == '<':
+ m = re.match(r'<([^>]+)=~([^>]+)>', s[pos:])
+ if m:
+ p = pos + m.end()
+ key = m.group(1)
+ pat = m.group(2)
+ return p, pattern.Condition(
+ lambda x: key in x and re.search(pat, x[key]))
+
m = re.match(r'<([^>]+)=([^>]+)>', s[pos:])
- if not m:
- raise InvalidPattern(pos)
- p = pos + m.end()
- key = m.group(1)
- value = m.group(2)
- return p, pattern.Condition(lambda x: key in x and x[key] == value)
+ if m:
+ p = pos + m.end()
+ key = m.group(1)
+ value = m.group(2)
+ return p, pattern.Condition(lambda x: key in x and x[key] == value)
+
+ raise InvalidPattern(pos)
elif c == '.':
return pos + 1, pattern.Condition(lambda x: True)
| unnonouno/mrep | 4f78ce20cd4f6d71baaea9679a65e4d074935f53 | diff --git a/test/builder_test.py b/test/builder_test.py
index 71560b5..c9d4026 100644
--- a/test/builder_test.py
+++ b/test/builder_test.py
@@ -18,6 +18,15 @@ class TermTest(unittest.TestCase):
t.match([{'x': 'y'}], 0, lambda s, p: ps.append(p))
self.assertEqual([1], ps)
+ def testPatternCondition(self):
+ p, t = mrep.builder.term('<x=~y>', 0)
+ self.assertIsNotNone(t)
+ self.assertEqual(6, p)
+ self.assertEqual('.', repr(t))
+ ps = []
+ t.match([{'x': 'zyw'}], 0, lambda s, p: ps.append(p))
+ self.assertEqual([1], ps)
+
def testParen(self):
p, t = mrep.builder.term('(.)', 0)
self.assertIsNotNone(t)
| Support regexp contidion
Users cannot find partially matched features such as "人名". I need to support regexp condition for this problem. | 0.0 | 4f78ce20cd4f6d71baaea9679a65e4d074935f53 | [
"test/builder_test.py::TermTest::testPatternCondition"
]
| [
"test/builder_test.py::TermTest::testCondition",
"test/builder_test.py::TermTest::testDot",
"test/builder_test.py::TermTest::testEOSbeforeClose",
"test/builder_test.py::TermTest::testInvalidCharacter",
"test/builder_test.py::TermTest::testInvalidPattern",
"test/builder_test.py::TermTest::testParen",
"test/builder_test.py::TermTest::testUnclosedParen",
"test/builder_test.py::StarTest::testNoStar",
"test/builder_test.py::StarTest::testStar",
"test/builder_test.py::SeqTest::testOne",
"test/builder_test.py::SeqTest::testSelect",
"test/builder_test.py::SeqTest::testSelectSeq",
"test/builder_test.py::SeqTest::testSelectThree",
"test/builder_test.py::SeqTest::testThree",
"test/builder_test.py::SeqTest::testTwo",
"test/builder_test.py::ExpTest::testRedundant",
"test/builder_test.py::InvalidCharacterTest::testOne",
"test/builder_test.py::InvalidCharacterTest::testThree",
"test/builder_test.py::InvalidCharacterTest::testTwo"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2016-04-15 08:32:38+00:00 | mit | 6,167 |
|
unt-libraries__django-nomination-109 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2757b5c..a8d28f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,7 +15,9 @@ Change Log
* Removed compatibility with Python 2
* Added slim-select for improved select inputs
* Prevent duplicates in url_report if a surt is duplicated in the data.
-
+* nominator_email is made unique.
+* Fixed admin links.
+* Used get_or_create and get_object_or_404 where appropriate.
2.0.0
-----
diff --git a/nomination/migrations/0005_auto_20210429_2207.py b/nomination/migrations/0005_auto_20210429_2207.py
new file mode 100644
index 0000000..50420b5
--- /dev/null
+++ b/nomination/migrations/0005_auto_20210429_2207.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.2.20 on 2021-04-29 22:07
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('nomination', '0004_auto_20190927_1904'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='nominator',
+ name='nominator_email',
+ field=models.CharField(help_text='An email address for identifying your nominations in the system.', max_length=100, unique=True),
+ ),
+ ]
diff --git a/nomination/models.py b/nomination/models.py
index 6a4573e..8c55514 100644
--- a/nomination/models.py
+++ b/nomination/models.py
@@ -2,6 +2,7 @@ import datetime
from django.db import models
from django.contrib.sites.models import Site
from django.conf import settings
+from django.utils.safestring import mark_safe
FORM_TYPES = (
('checkbox', 'checkbox'),
@@ -207,6 +208,7 @@ class Nominator(models.Model):
)
nominator_email = models.CharField(
max_length=100,
+ unique=True,
help_text='An email address for identifying your nominations in the system.'
)
@@ -234,7 +236,7 @@ class URL(models.Model):
return self.entity
def entity_display(self):
- return(
+ return mark_safe(
"<a href=\'http://%s/admin/nomination/url/%s\'>%s</a> "
"<a href=\'%s\'><img src=\'%snomination/images/external-link.gif\'/></a>"
% (Site.objects.get_current().domain, self.id, self.entity, self.entity,
@@ -244,13 +246,15 @@ class URL(models.Model):
entity_display.allow_tags = True
def get_project(self):
- return "<a href=\'http://%s/admin/nomination/project/%s\'>%s</a>" % \
- (Site.objects.get_current().domain, self.url_project.id, self.url_project)
+ return mark_safe(
+ "<a href=\'http://%s/admin/nomination/project/%s\'>%s</a>" %
+ (Site.objects.get_current().domain, self.url_project.id, self.url_project))
get_project.short_description = 'Project'
get_project.allow_tags = True
def get_nominator(self):
- return "<a href=\'http://%s/admin/nomination/nominator/%s\'>%s</a>" % \
- (Site.objects.get_current().domain, self.url_nominator.id, self.url_nominator)
+ return mark_safe(
+ "<a href=\'http://%s/admin/nomination/nominator/%s\'>%s</a>" %
+ (Site.objects.get_current().domain, self.url_nominator.id, self.url_nominator))
get_nominator.short_description = 'Nominator'
get_nominator.allow_tags = True
diff --git a/nomination/url_handler.py b/nomination/url_handler.py
index 810205c..320fc3e 100644
--- a/nomination/url_handler.py
+++ b/nomination/url_handler.py
@@ -8,6 +8,8 @@ from urllib.parse import urlparse
from django import http
from django.conf import settings
+from django.shortcuts import get_object_or_404
+from django.db import IntegrityError
from nomination.models import Project, Nominator, URL, Value
@@ -121,10 +123,7 @@ def add_url(project, form_data):
summary_list = []
form_data['url_value'] = check_url(form_data['url_value'])
# Get the system nominator
- try:
- system_nominator = Nominator.objects.get(id=settings.SYSTEM_NOMINATOR_ID)
- except Nominator.DoesNotExist:
- raise http.Http404
+ system_nominator = get_object_or_404(Nominator, id=settings.SYSTEM_NOMINATOR_ID)
# Check for or add surt
surt_successful = surt_exists(project, system_nominator, form_data['url_value'])
@@ -134,7 +133,7 @@ def add_url(project, form_data):
# Get/Add a nominator
nominator = get_nominator(form_data)
if not nominator:
- raise http.Http404
+ return False
# Nominate a URL
summary_list = nominate_url(project, nominator, form_data, '1')
@@ -172,17 +171,27 @@ def check_url(url):
def get_nominator(form_data):
try:
# Try to retrieve the nominator
- nominator = Nominator.objects.get(nominator_email=form_data['nominator_email'])
- except (Nominator.DoesNotExist, Nominator.MultipleObjectsReturned):
+ nominator, created = Nominator.objects.get_or_create(
+ nominator_email=form_data['nominator_email'],
+ defaults={
+ 'nominator_name': form_data['nominator_name'],
+ 'nominator_institution': form_data['nominator_institution']
+ })
+
+ except Nominator.MultipleObjectsReturned:
+ # Retrieve unique nominator
try:
- # Create a new nominator object
- nominator = Nominator(nominator_email=form_data['nominator_email'],
- nominator_name=form_data['nominator_name'],
- nominator_institution=form_data['nominator_institution'])
- nominator.save()
- except Exception:
+ nominator = Nominator.objects.get(
+ nominator_email=form_data['nominator_email'],
+ nominator_name=form_data['nominator_name'],
+ nominator_institution=form_data['nominator_institution'])
+
+ except (Nominator.MultipleObjectsReturned, Nominator.DoesNotExist):
return False
+ except (IntegrityError, KeyError):
+ raise http.Http404
+
return nominator
@@ -191,23 +200,21 @@ def nominate_url(project, nominator, form_data, scope_value):
# Nominate URL
try:
# Check if user has already nominated the URL
- nomination_url = URL.objects.get(url_nominator__id__iexact=nominator.id,
- url_project=project,
- entity__iexact=form_data['url_value'],
- attribute__iexact='nomination')
+ nomination_url, created = URL.objects.get_or_create(url_nominator__id__iexact=nominator.id,
+ url_project=project,
+ entity__iexact=form_data['url_value'],
+ attribute__iexact='nomination',
+ defaults={
+ 'entity': form_data['url_value'],
+ 'attribute': 'nomination',
+ 'value': scope_value,
+ 'url_nominator': nominator,
+ })
except Exception:
- try:
- # Nominate URL
- nomination_url = URL(entity=form_data['url_value'],
- value=scope_value,
- attribute='nomination',
- url_project=project,
- url_nominator=nominator)
- nomination_url.save()
- except Exception:
- raise http.Http404
- else:
- summary_list.append('You have successfully nominated ' + form_data['url_value'])
+ raise http.Http404
+
+ if created:
+ summary_list.append('You have successfully nominated ' + form_data['url_value'])
else:
if nomination_url.value == scope_value:
if scope_value == '1':
@@ -267,25 +274,23 @@ def save_attribute(project, nominator, form_data, summary_list, attribute_name,
"""
try:
# Check if URL attribute and value already exist
- added_url = URL.objects.get(url_nominator=nominator,
- url_project=project,
- entity__iexact=form_data['url_value'],
- value__iexact=valvar,
- attribute__iexact=attribute_name)
- except (URL.DoesNotExist, URL.MultipleObjectsReturned):
- try:
- added_url = URL(entity=form_data['url_value'],
- value=valvar,
- attribute=attribute_name,
- url_project=project,
- url_nominator=nominator)
- added_url.save()
- except Exception:
- raise http.Http404
- else:
- summary_list.append('You have successfully added the '
- + attribute_name + ' \"' + valvar + '\" for '
- + form_data['url_value'])
+ added_url, created = URL.objects.get_or_create(url_nominator=nominator,
+ url_project=project,
+ entity__iexact=form_data['url_value'],
+ value__iexact=valvar,
+ attribute__iexact=attribute_name,
+ defaults={
+ 'entity': form_data['url_value'],
+ 'value': valvar,
+ 'attribute': attribute_name,
+ })
+ except Exception:
+ raise http.Http404
+
+ if created:
+ summary_list.append('You have successfully added the '
+ + attribute_name + ' \"' + valvar + '\" for '
+ + form_data['url_value'])
else:
summary_list.append('You have already added the '
+ attribute_name + ' \"' + valvar + '\" for '
@@ -297,17 +302,17 @@ def save_attribute(project, nominator, form_data, summary_list, attribute_name,
def surt_exists(project, system_nominator, url_entity):
# Create a SURT if the url doesn't already have one
try:
- URL.objects.get(url_project=project, entity__iexact=url_entity, attribute__iexact='surt')
- except URL.DoesNotExist:
- try:
- new_surt = URL(entity=url_entity,
- value=surtize(url_entity),
- attribute='surt',
- url_project=project,
- url_nominator=system_nominator)
- new_surt.save()
- except Exception:
- raise http.Http404
+ URL.objects.get_or_create(url_project=project,
+ entity__iexact=url_entity,
+ attribute__iexact='surt',
+ defaults={
+ 'entity': url_entity,
+ 'attribute': 'surt',
+ 'value': surtize(url_entity),
+ 'url_nominator': system_nominator
+ })
+ except Exception:
+ raise http.Http404
return True
@@ -406,10 +411,7 @@ def create_json_browse(slug, url_attribute, root=''):
json_list = []
# Make sure the project exist in the database
- try:
- project = Project.objects.get(project_slug=slug)
- except Project.DoesNotExist:
- raise http.Http404
+ project = get_object_or_404(Project, project_slug=slug)
if root != '':
# Find all URLs with the project and domain specified
@@ -489,10 +491,7 @@ def create_json_browse(slug, url_attribute, root=''):
def create_json_search(slug):
"""Create JSON list of all URLs added to the specified project."""
- try:
- project = Project.objects.get(project_slug=slug)
- except Project.DoesNotExist:
- raise http.Http404
+ project = get_object_or_404(Project, project_slug=slug)
json_list = []
query_list = (URL.objects.filter(url_project=project)
diff --git a/nomination/views.py b/nomination/views.py
index 85de2b7..3f9ed7b 100644
--- a/nomination/views.py
+++ b/nomination/views.py
@@ -481,6 +481,13 @@ def url_add(request, slug):
posted_data = handle_metadata(request, posted_data)
summary_list = add_url(project, posted_data)
+ if not summary_list:
+ return HttpResponse('There was a problem processing your nominator '
+ 'details. Please contact {admin_email} for '
+ 'assistance and provide the name, email address,'
+ ' and institution you are using for nominations.'
+ .format(admin_email=project.admin_email),
+ content_type='text/plain')
# send url value to provide metadata link
url_entity = posted_data['url_value']
# clear out posted data, so it is not sent back to form
| unt-libraries/django-nomination | 0bf57406aee3d71fae35e0ad791450445328ac4b | diff --git a/tests/test_url_handler.py b/tests/test_url_handler.py
index 9b3877e..1da2af8 100644
--- a/tests/test_url_handler.py
+++ b/tests/test_url_handler.py
@@ -195,6 +195,8 @@ class TestAddMetadata():
value = 'some_value'
form_data = {
'nominator_email': nominator.nominator_email,
+ 'nominator_institution': nominator.nominator_institution,
+ 'nominator_name': nominator.nominator_name,
'scope': '1',
'url_value': 'http://www.example.com',
attribute_name: value
@@ -229,7 +231,11 @@ class TestGetNominator():
def test_returns_nominator(self):
nominator = factories.NominatorFactory()
- form_data = {'nominator_email': nominator.nominator_email}
+ form_data = {
+ 'nominator_email': nominator.nominator_email,
+ 'nominator_name': nominator.nominator_name,
+ 'nominator_institution': nominator.nominator_institution
+ }
assert url_handler.get_nominator(form_data) == nominator
def test_creates_and_returns_nominator(self):
@@ -251,9 +257,8 @@ class TestGetNominator():
'nominator_name': None,
'nominator_institution': None
}
- new_nominator = url_handler.get_nominator(form_data)
-
- assert new_nominator is False
+ with pytest.raises(http.Http404):
+ url_handler.get_nominator(form_data)
class TestNominateURL():
| Use get_object_or_404
We really should be using [get_object_or_404](https://docs.djangoproject.com/en/1.11/topics/http/shortcuts/#get-object-or-404) any place that will grabbing a database record based on the URL, such as [here](https://github.com/unt-libraries/django-nomination/blob/master/nomination/views.py#L841). Would help to avoid some unnecessary server errors. | 0.0 | 0bf57406aee3d71fae35e0ad791450445328ac4b | [
"tests/test_url_handler.py::TestGetNominator::test_cannot_create_nominator"
]
| [
"tests/test_url_handler.py::TestAlphabeticalBrowse::test_returns_browse_dict",
"tests/test_url_handler.py::TestAlphabeticalBrowse::test_no_valid_surts_found[http://(,)-expected0]",
"tests/test_url_handler.py::TestAlphabeticalBrowse::test_no_valid_surts_found[http://(org,)-expected1]",
"tests/test_url_handler.py::TestAlphabeticalBrowse::test_project_not_found",
"tests/test_url_handler.py::TestGetMetadata::test_returns_metadata_list",
"tests/test_url_handler.py::TestGetMetadata::test_metadata_list_includes_valueset_values",
"tests/test_url_handler.py::test_handle_metadata[posted_data0-processed_posted_data0-expected0]",
"tests/test_url_handler.py::test_handle_metadata[posted_data1-processed_posted_data1-expected1]",
"tests/test_url_handler.py::test_handle_metadata[posted_data2-processed_posted_data2-expected2]",
"tests/test_url_handler.py::test_handle_metadata[posted_data3-processed_posted_data3-expected3]",
"tests/test_url_handler.py::TestValidateDate::test_returns_valid_date[2006-10-25]",
"tests/test_url_handler.py::TestValidateDate::test_returns_valid_date[10/25/2006]",
"tests/test_url_handler.py::TestValidateDate::test_returns_valid_date[10/25/06]",
"tests/test_url_handler.py::TestValidateDate::test_returns_valid_date[Oct",
"tests/test_url_handler.py::TestValidateDate::test_returns_valid_date[25",
"tests/test_url_handler.py::TestValidateDate::test_returns_valid_date[October",
"tests/test_url_handler.py::TestValidateDate::test_returns_none_with_invalid_date",
"tests/test_url_handler.py::TestAddURL::test_returns_expected",
"tests/test_url_handler.py::TestAddURL::test_cannot_get_system_nominator",
"tests/test_url_handler.py::TestAddURL::test_cannot_get_or_create_nominator",
"tests/test_url_handler.py::TestAddMetadata::test_returns_expected",
"tests/test_url_handler.py::TestAddMetadata::test_nominator_not_found",
"tests/test_url_handler.py::test_check_url[http://www.example.com-http://www.example.com]",
"tests/test_url_handler.py::test_check_url[",
"tests/test_url_handler.py::test_check_url[https://www.example.com-https://www.example.com]",
"tests/test_url_handler.py::test_check_url[http://www.example.com///-http://www.example.com]",
"tests/test_url_handler.py::TestGetNominator::test_returns_nominator",
"tests/test_url_handler.py::TestGetNominator::test_creates_and_returns_nominator",
"tests/test_url_handler.py::TestNominateURL::test_nomination_exists[1-In",
"tests/test_url_handler.py::TestNominateURL::test_nomination_exists[0-Out",
"tests/test_url_handler.py::TestNominateURL::test_nomination_gets_modified[1-In",
"tests/test_url_handler.py::TestNominateURL::test_nomination_gets_modified[0-Out",
"tests/test_url_handler.py::TestNominateURL::test_creates_new_nomination",
"tests/test_url_handler.py::TestNominateURL::test_cannot_create_nomination",
"tests/test_url_handler.py::TestAddOtherAttribute::test_returns_expected",
"tests/test_url_handler.py::TestAddOtherAttribute::test_returns_expected_with_multiple_attribute_values",
"tests/test_url_handler.py::TestSaveAttribute::test_creates_url",
"tests/test_url_handler.py::TestSaveAttribute::test_does_not_create_url_if_it_exists_already",
"tests/test_url_handler.py::TestSaveAttribute::test_url_cannot_be_saved",
"tests/test_url_handler.py::TestSurtExists::test_returns_true_with_existing_surt",
"tests/test_url_handler.py::TestSurtExists::test_creates_surt_when_surt_does_not_exist",
"tests/test_url_handler.py::TestSurtExists::test_surt_cannot_be_created",
"tests/test_url_handler.py::test_url_formatter[www.example.com-http://www.example.com]",
"tests/test_url_handler.py::test_url_formatter[",
"tests/test_url_handler.py::test_surtize[http://[email protected]:80/path?query#fragment-False-http://(tld,domain,:80@userinfo)/path?query#fragment]",
"tests/test_url_handler.py::test_surtize[http://www.example.com-False-http://(com,example,www,)]",
"tests/test_url_handler.py::test_surtize[ftp://www.example.com-False-ftp://(com,example,www,)]",
"tests/test_url_handler.py::test_surtize[ftps://www.example.com-False-ftp://(com,example,www,)]",
"tests/test_url_handler.py::test_surtize[https://www.example.com-False-http://(com,example,www,)]",
"tests/test_url_handler.py::test_surtize[www.example.com-False-http://(com,example,www,)]",
"tests/test_url_handler.py::test_surtize[http://www.eXaMple.cOm-True-http://(cOm,eXaMple,www,)]",
"tests/test_url_handler.py::test_surtize[Not",
"tests/test_url_handler.py::test_surtize[1.2.3.4:80/examples-False-http://(1.2.3.4:80)/examples]",
"tests/test_url_handler.py::test_appendToSurt",
"tests/test_url_handler.py::test_addImpliedHttpIfNecessary[http://www.example.com-http://www.example.com]",
"tests/test_url_handler.py::test_addImpliedHttpIfNecessary[www.example.com-http://www.example.com]",
"tests/test_url_handler.py::test_addImpliedHttpIfNecessary[:.-:.]",
"tests/test_url_handler.py::test_addImpliedHttpIfNecessary[.:-http://.:]",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_returns_expected[com,-<a",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_returns_expected[-com-com,]",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_handles_non_http[com,-<a",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_handles_non_http[-com-com,]",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_returns_expected_with_no_children",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_does_not_show_duplicates[com,-<a",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_does_not_show_duplicates[-com-com,]",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_groups_by_prefix_when_many_urls_exist",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_cannot_find_project",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_cannot_find_matching_surts",
"tests/test_url_handler.py::TestCreateJsonBrowse::test_empty_root",
"tests/test_url_handler.py::TestCreateJsonSearch::test_returns_expected",
"tests/test_url_handler.py::TestCreateJsonSearch::test_project_not_found",
"tests/test_url_handler.py::TestCreateURLList::test_returns_expected",
"tests/test_url_handler.py::TestCreateURLList::test_returns_expected_with_project_metadata_values",
"tests/test_url_handler.py::TestCreateURLDump::test_returns_expected_with_nomination",
"tests/test_url_handler.py::TestCreateURLDump::test_returns_expected_with_surt",
"tests/test_url_handler.py::TestCreateURLDump::test_returns_correct_attribute",
"tests/test_url_handler.py::TestCreateURLDump::test_returns_correct_attribute_with_new_value",
"tests/test_url_handler.py::TestCreateSurtDict::test_returns_expected[http://(com,example,www,)-False]",
"tests/test_url_handler.py::TestCreateSurtDict::test_returns_expected[http://(com,a,-a]",
"tests/test_url_handler.py::TestCreateSurtDict::test_returns_none_when_no_surts_found",
"tests/test_url_handler.py::test_get_domain_surt[http://(com,example,www,)-http://(com,example,]",
"tests/test_url_handler.py::test_get_domain_surt[http://(uk,gov,nationalarchives,www,)-http://(uk,gov,]",
"tests/test_url_handler.py::test_get_domain_surt[http://not-a-surt.com-http://not-a-surt.com]",
"tests/test_url_handler.py::test_fix_scheme_double_slash",
"tests/test_url_handler.py::test_fix_scheme_double_slash_ftp",
"tests/test_url_handler.py::test_strip_scheme"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks",
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-04-15 21:16:22+00:00 | bsd-3-clause | 6,168 |
|
unt-libraries__edtf-validate-21 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ad73c9..8c1562d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@ Change Log
==========
+1.1.1
+=====
+
+* Fixed error on `is_valid` when checking an [interval with a season](https://github.com/unt-libraries/edtf-validate/issues/20).
+* In README.md, updated draft EDTF specification link to fix the 404.
+
1.1.0
=====
diff --git a/edtf_validate/valid_edtf.py b/edtf_validate/valid_edtf.py
index 8867384..b4702f8 100644
--- a/edtf_validate/valid_edtf.py
+++ b/edtf_validate/valid_edtf.py
@@ -73,7 +73,7 @@ LEVEL 1 GRAMMAR START
UASymbol = oneOf("? ~ ?~")
seasonNumber = oneOf("21 22 23 24")
season = year + "-" + seasonNumber
-dateOrSeason = date | season
+dateOrSeason = season | date
# uncertain Or Approximate Date
uncertainOrApproxDate = date + UASymbol
# unspecified
@@ -249,6 +249,28 @@ def replace_all(text, dic):
return text
+# season start and end dates for use in interval checking
+# erring toward inclusivity
+seasons = {
+ '21': {'from': '01', 'to': '05'},
+ '22': {'from': '05', 'to': '08'},
+ '23': {'from': '08', 'to': '11'},
+ '24': {'from': '10', 'to': '12'},
+}
+
+
+def replace_season(season_date, marker):
+ """Replace a season with a month.
+
+ Keyword arguments:
+ season_date -- edtf candidate of form year-season
+ marker -- 'from' or 'to' representing earliest or latest season month
+ """
+ y_part, m_part = season_date.split('-')
+ m_part = seasons[m_part][marker]
+ return '-'.join([y_part, m_part])
+
+
U_PATTERN = re.compile(r'(-?)([\du]{4})(-[\du]{2})?(-[\du]{2})?/'
r'(-?)([\du]{4})(-[\du]{2})?(-[\du]{2})?')
@@ -441,11 +463,28 @@ def is_valid_interval(edtf_candidate):
from_date = datetime.datetime.strptime(parts[0], "%Y-%m-%d")
if parts[1].count("-") == 2:
to_date = datetime.datetime.strptime(parts[1], "%Y-%m-%d")
+ # handle special case of same year season/season range due to
+ # the overlap of the months we are designating for the seasons
+ if parts[0].count("-") == 1 and parts[1].count("-") == 1:
+ from_year, from_month = parts[0].split("-")
+ to_year, to_month = parts[1].split("-")
+ if from_year == to_year and from_month in seasons and to_month in seasons:
+ return from_month <= to_month
# 1 '-' character means we are match year-month
if parts[0].count("-") == 1:
- from_date = datetime.datetime.strptime(parts[0], "%Y-%m")
+ try:
+ from_date = datetime.datetime.strptime(parts[0], "%Y-%m")
+ except ValueError:
+ # month is a season; use earliest possible month
+ replaced_season = replace_season(parts[0], 'from')
+ from_date = datetime.datetime.strptime(replaced_season, "%Y-%m")
if parts[1].count("-") == 1:
- to_date = datetime.datetime.strptime(parts[1], "%Y-%m")
+ try:
+ to_date = datetime.datetime.strptime(parts[1], "%Y-%m")
+ except ValueError:
+ # month is a season; use latest possible month
+ replaced_season = replace_season(parts[1], 'to')
+ to_date = datetime.datetime.strptime(replaced_season, "%Y-%m")
# zero '-' characters means we are matching a year
if parts[0].count("-") == 0:
# if from_date is unknown, we can assume the lowest possible date
| unt-libraries/edtf-validate | 7b10fb2b3d3c70e12f55a41295e4f39a734b192f | diff --git a/tests/test_valid_edtf.py b/tests/test_valid_edtf.py
index 94a77d0..1b496d0 100644
--- a/tests/test_valid_edtf.py
+++ b/tests/test_valid_edtf.py
@@ -42,11 +42,19 @@ class TestIsValid(object):
'1111-01-01/1111',
'0000-01/0000',
'2000-uu/2012',
+ '1952-23~/1953',
+ '1923-21/1924',
+ '1981/1982-23',
+ '1623-11/1900-11',
+ '2003-22/2004-22',
+ '2003-22/2003-22',
+ '2003-22/2003-23',
'2000-12-uu/2012',
'2000-uu-10/2012',
'-2000-uu-10/2012',
'2000-uu-uu/2012',
'2000/2000-uu-uu',
+ '1712/2012',
'198u/199u',
'198u/1999',
'1987/199u',
@@ -87,6 +95,8 @@ class TestIsValid(object):
'2012///4444',
'2012\\2013',
'2000/12-12',
+ '2012-24/2012-21',
+ '2012-23/2012-22',
'0800/-0999',
'-1000/-2000',
'1000/-2000',
| `is_valid` errors on an interval with a season
Example is `is_valid('2012/2019-22')` due to [`to_date = datetime.datetime.strptime(parts[1], "%Y-%m")`] not being able to parse a season (i.e. 21, 22, 23, or 24) in the month place. Though it is not completely clear to some of us in the draft specification we are following if a season in the interval should be valid, I think @htarver wants this to be valid assuming the interval makes sense as far as the end date coming after the start date. Valid or not, we should avoid the exception. | 0.0 | 7b10fb2b3d3c70e12f55a41295e4f39a734b192f | [
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1952-23~/1953]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1923-21/1924]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1981/1982-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2003-22/2003-23]"
]
| [
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10T10:10:1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10T1:10:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10T10:1:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10t10:10:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10T10:10:10Z10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[1960-06-31]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[[1",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_datetime",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1000/-0999]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1000/-0090-10]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1000/2000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1000/2000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[unknown/2000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[unknown/open]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2017-01-14/open]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000-02/1111]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000-01/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000-uu/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1623-11/1900-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000-12-uu/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000-uu-10/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-2000-uu-10/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000-uu-uu/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000/2000-uu-uu]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1712/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[198u/199u]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[198u/1999]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1987/199u]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1984-11-2u/1999-01-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1984-11-12/1984-11-uu]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[198u-11-uu/198u-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-uu-02/1919-uu-01_0]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-0u-02/1919-01-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1865-u2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1981-11-10/1980-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1930-u0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1981-1u-10/1981-11-09]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-12-02/1919-uu-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-11-02/1919-1u-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-09-02/1919-u0-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-08-02/1919-0u-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-10-02/1919-u1-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-04-01/1919-u4-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1602-10-0u/1602-10-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2018-05-u0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-2018-05-u0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1200-01-u4/1200-01-08]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-uu-02/1919-uu-01_1]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-07-30/1919-07-3u]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1908-05-02/1908-05-0u]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0501-11-18/0501-11-1u]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1112-08-22/1112-08-2u]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2015-02-27/2015-02-u8]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2016-02-28/2016-02-u9]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012/2013/1234/55BULBASAUR]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[NONE/unknown]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012///4444]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012\\\\2013]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2000/12-12]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012-24/2012-21]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012-23/2012-22]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0800/-0999]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[-1000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[1000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[y-61000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0001/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0000-01-03/0000-01]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0000/-0001]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0000-02/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[+20067890?~0]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[y2006]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[-0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[+y20067890-14-10?~]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[+20067890?~1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[+2006?~]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2001-02-03]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2008-12]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2008]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[-0999]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[-9999]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2001-02-03T09:30:01]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-01-01T10:10:10Z]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2012-10-10T10:10:10Z]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[-2012-10-10T10:10:10Z]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-01-01T10:10:10+05:00]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1964/2008]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2005/2006-02]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-03",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-03-",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-03-29",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[18",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-0",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1984?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06-11?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984?~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[199u]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[19uu]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-19uu]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1999-uu]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1999-01-uu]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1999-uu-uu]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1999-uu-uu]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[unknown/2006]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06-01/unknown]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06-01/unknown]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-01-01/open]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~/2004-06]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984/2004-06~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~/2004~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984?/2004?~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06-02?/unknown]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[y170000002]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[y-170000002]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2001-21]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003-22]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2003-22]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2000-23]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2010-24]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-06-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-06-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06~-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-(06)?-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-(11)~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-06-(11)~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-(06)?~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-(06-11)?]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-06-(11)~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[(2004-(06)~)?]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-(06)?~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[(2004)?-06-04~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[(2011)-06-04~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2011-(06-04)~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2011-23~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2011-23~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[156u-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[15uu-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[15uu-12-uu]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-15uu-12-uu]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1560-uu-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1667,1668,",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1760-12..]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1760-01,",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1760-01,",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1667,",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{1667,1668,",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{1960,",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[196x]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[19xx]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-19xx]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-(01)~/2004-06-(20)~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-uu/2004-07-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[y17e7]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[y-17e7]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[y17101e4p3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-21^southernHemisphere]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1960-06-31]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[[1"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2020-02-17 18:52:13+00:00 | bsd-3-clause | 6,169 |
|
unt-libraries__edtf-validate-25 | diff --git a/edtf_validate/valid_edtf.py b/edtf_validate/valid_edtf.py
index a4e0cdc..6648d02 100644
--- a/edtf_validate/valid_edtf.py
+++ b/edtf_validate/valid_edtf.py
@@ -529,7 +529,7 @@ def is_valid_interval(edtf_candidate):
def isLevel0(edtf_candidate):
- """Checks to see if the date is level 0 valid"""
+ """Check if the date is of a feature introduced in level 0."""
if " " not in edtf_candidate:
result = edtf_candidate == level0Expression
@@ -539,7 +539,7 @@ def isLevel0(edtf_candidate):
def isLevel1(edtf_candidate):
- """Checks to see if the date is level 1 valid"""
+ """Check if the date is of a feature introduced in level 1."""
if " " not in edtf_candidate:
result = edtf_candidate == level1Expression
@@ -549,7 +549,7 @@ def isLevel1(edtf_candidate):
def isLevel2(edtf_candidate):
- """Checks to see if the date is level 2 valid"""
+ """Check if the date is of a feature introduced in level 2."""
if "[" in edtf_candidate or "{" in edtf_candidate:
result = edtf_candidate == level2Expression
@@ -560,6 +560,25 @@ def isLevel2(edtf_candidate):
return result
+def conformsLevel0(edtf_candidate):
+ """Check if the date is supported at level 0."""
+ return isLevel0(edtf_candidate)
+
+
+def conformsLevel1(edtf_candidate):
+ """Check if the date is supported at level 1."""
+ return isLevel0(edtf_candidate) or isLevel1(edtf_candidate)
+
+
+def conformsLevel2(edtf_candidate):
+ """Check if the date is supported at level 2."""
+ return(
+ isLevel0(edtf_candidate)
+ or isLevel1(edtf_candidate)
+ or isLevel2(edtf_candidate)
+ )
+
+
def is_valid(edtf_candidate):
"""isValid takes a candidate date and returns if it is valid or not"""
if (
| unt-libraries/edtf-validate | 4812e88f94df67690a5aa83ad2e7420a5d62c0bc | diff --git a/tests/test_valid_edtf.py b/tests/test_valid_edtf.py
index 6d7dd17..003c098 100644
--- a/tests/test_valid_edtf.py
+++ b/tests/test_valid_edtf.py
@@ -1,7 +1,7 @@
import pytest
-from edtf_validate.valid_edtf import (is_valid_interval, is_valid, isLevel0,
- isLevel1, isLevel2)
+from edtf_validate.valid_edtf import (is_valid_interval, is_valid, isLevel0, isLevel1,
+ isLevel2, conformsLevel0, conformsLevel1, conformsLevel2)
class TestIsValidInterval(object):
@@ -307,3 +307,69 @@ class TestLevel2(object):
])
def test_invalid_level_2(self, date):
assert not isLevel2(date)
+
+ @pytest.mark.parametrize('date', [
+ '1985',
+ '2004/2005',
+ '1985-04-12',
+ '1985-04-12T23:20:30Z',
+ '1985-04-12T23:20:30+04:30'
+ ])
+ def test_valid_conformsLevel0(self, date):
+ assert conformsLevel0(date)
+
+ @pytest.mark.parametrize('date', [
+ '-1984',
+ '19XX',
+ 'Y-170000002',
+ '2001-21',
+ '1984?',
+ '1985-04/..',
+ '1985/',
+ ])
+ def test_invalid_conformsLevel0(self, date):
+ assert not conformsLevel0(date)
+
+ @pytest.mark.parametrize('date', [
+ '-1985',
+ '/1985-04-12',
+ '../1985-04-12',
+ '2004-XX',
+ '2004-06~',
+ '2001-21',
+ 'Y-170000002',
+ '1985-04-12T23:20:30Z',
+ '2004-06/2006-08',
+ '1985-04'
+ ])
+ def test_valid_conformsLevel1(self, date):
+ assert conformsLevel1(date)
+
+ @pytest.mark.parametrize('date', [
+ 'Y-17E7',
+ '2001-34',
+ '156X-12-25'
+ ])
+ def test_invalid_conformsLevel1(self, date):
+ assert not conformsLevel1(date)
+
+ @pytest.mark.parametrize('date', [
+ '-1985',
+ '/1985-04-12',
+ '../1985-04-12',
+ '2004-XX',
+ '2004-06~',
+ '2001-21',
+ 'Y-170000002',
+ '1985-04-12T23:20:30Z',
+ '2004-06/2006-08',
+ '1985-04',
+ '156X-12-25',
+ '{1667,1668,1670..1672}',
+ '[1667,1668,1670..1672]',
+ ])
+ def test_valid_conformsLevel2(self, date):
+ assert conformsLevel2(date)
+
+ def test_invalid_conformsLevel2(self):
+ assert not conformsLevel2('[1667,1668, 1670..1672]')
| Support checking level conformance and level is-a-feature-of
To facilitate the work on changes to the edtf-service described at: https://github.com/unt-libraries/django-edtf/issues/15, we will probably need to replace `isLevel0`, `isLevel1`, `isLevel2` with functionality that distinguishes if the date conforms to a specific level or is a feature of a specific level. | 0.0 | 4812e88f94df67690a5aa83ad2e7420a5d62c0bc | [
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10T10:10:1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10T1:10:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10T10:1:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10t10:10:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[2012-10-10T10:10:10Z10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[1960-06-31]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_datetime[[1",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_datetime",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1000/-0999]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1000/-0090-10]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1000/2000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1000/2000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[/2000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[../]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[../1985-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2001-34]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2017-01-14/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000-02/1111]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0000-01/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1952-23~/1953]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1923-21/1924]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1981/1982-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1623-11/1900-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000-XX-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1712/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[198X/199X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[198X/1999]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1987/199X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-XX-02/1919-XX-01_0]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-1981-11-10/1980-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-XX-02/1919-XX-01_1]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_interval[-2001-02-03]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012/2013/1234/55BULBASAUR]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[NONE/]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012///4444]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012\\\\2013]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2000/12-12]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012-24/2012-21]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[2012-23/2012-22]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0800/-0999]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[-1000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[1000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[Y-61000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0001/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0000-01-03/0000-01]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0000/-0001]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_interval[0000-02/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[+20067890%0]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[Y2006]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[-0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[+Y20067890-14-10%]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[+20067890%1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_date_match[+2006%]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2001-02-03]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2008-12]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2008]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2001-02-03T09:30:01]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-01-01T10:10:10Z]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2012-10-10T10:10:10Z]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-01-01T10:10:10+05:00]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1964/2008]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2005/2006-02]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-03",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-03-",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-03-29",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[18",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1863-0",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1959]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1984?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06-11?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[199X]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[19XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-19XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1999-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1999-01-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1999-XX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1999-XX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/2006]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06-01/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06-01/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-01-01/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~/2004-06]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984/2004-06~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~/2004~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1984?/2004%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06-02?/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[Y170000002]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2001-21]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003-22]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2003-22]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2000-23]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2010-24]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1000/-0999]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2012-10-10T10:10:10Z]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06-01/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../-2004-02-01]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2019-12/2020%]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-06-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06~-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-?06-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-?06-?11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-~11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06-04~0]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-?11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06-04~1]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2011-06-~04]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2011-23~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-06-11_0]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-06~-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-?06-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-?06-?11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-06-~11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-06-?11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1529-?09-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-06-11_1]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[%-2011-06-13]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[15XX-12-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-15XX-12-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1560-XX-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1760-12..]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1760-01,1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1760-01,1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1667,1760-12]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-~01/2004-06-~20_0]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{1960,1961-12}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-~01/2004-06-~20_1]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y17E7]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y-17E7]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y17101E4S3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1950S2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y171010000S3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-29]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-34]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2019-12/%2020]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-~01/2004-06-~20_2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[%2001]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2019-12/~2020]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1960-06-31]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[[1",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[[1667,1668,",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[196X]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[19XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-19XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2001-21^southernHemisphere]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[Y170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1998]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2006%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04/2020~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2019-12/2020%0]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1984?/2004%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984-06-02?/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2019-12/2020%1]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06-11%/2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2012-10-10T10:10:10Z]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1000/-0999]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel0[1985]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel0[2004/2005]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel0[1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel0[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel0[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel0[-1984]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel0[19XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel0[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel0[2001-21]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel0[1984?]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel0[1985-04/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel0[1985/]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[-1985]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[/1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[../1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[2004-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[2001-21]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel1[1985-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel1[Y-17E7]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel1[2001-34]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel1[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[-1985]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[/1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[../1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[2004-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[2001-21]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[1985-04]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[{1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_conformsLevel2[[1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_conformsLevel2"
]
| []
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2020-07-27 22:18:15+00:00 | bsd-3-clause | 6,170 |
|
unt-libraries__edtf-validate-29 | diff --git a/edtf_validate/valid_edtf.py b/edtf_validate/valid_edtf.py
index 6648d02..53dd491 100644
--- a/edtf_validate/valid_edtf.py
+++ b/edtf_validate/valid_edtf.py
@@ -55,11 +55,11 @@ day = oneThru31
non_negative_date = non_negative_yearMonthDay | non_negative_yearMonth | non_negative_year
baseTime = hour + ":" + minute + ":" + second | "24:00:00"
zoneOffsetHour = oneThru13
-zoneOffset = "Z" | (
- oneOf("+ -") + zoneOffsetHour + Optional(":" + minute)
+zoneOffset = "Z" | (oneOf("+ -") + (
+ zoneOffsetHour + Optional(":" + minute)
| "14:00"
| "00:" + oneThru59
-)
+))
time = baseTime + Optional(zoneOffset)
dateAndTime = non_negative_date + "T" + time
L0Interval = non_negative_date + "/" + non_negative_date
| unt-libraries/edtf-validate | 7648c3f1c7ce3a8fd8b398fc121c9a29d62f9649 | diff --git a/tests/test_valid_edtf.py b/tests/test_valid_edtf.py
index a9b4d84..b74d118 100644
--- a/tests/test_valid_edtf.py
+++ b/tests/test_valid_edtf.py
@@ -122,7 +122,7 @@ Level0 = list(chain([
'1985-04-12T23:20:30Z',
'1985-04-12T23:20:30-04',
'1985-04-12T23:20:30+04:30',
- pytest.param('2004-01-01T10:10:10+00:59', marks=pytest.mark.xfail),
+ '2004-01-01T10:10:10+00:59',
], L0_Intervals))
Level1 = list(chain([
@@ -284,7 +284,7 @@ invalid_edtf_datetimes = [
'2004-01-01T10:10:40Z00:60',
'2004-01-01T10:10:10-05:60',
'2004-01-01T10:10:10+02:00:30',
- pytest.param('2004-01-01T10:10:1000:59', marks=pytest.mark.xfail),
+ '2004-01-01T10:10:1000:59',
'-1985-04-12T23:20:30+24',
'-1985-04-12T23:20:30Z12:00',
]
| Add '+' or '-' to zoneOffset var to indicate timezone being ahead or behind UTC. | 0.0 | 7648c3f1c7ce3a8fd8b398fc121c9a29d62f9649 | [
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:1000:59]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-01-01T10:10:10+00:59]"
]
| [
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012/2013/1234/55BULBASAUR]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012///4444]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012\\\\2013]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012-24/2012-21]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012-23/2012-22]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0800/-0999]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[-1000/-2000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[1000/-2000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0001/0000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0000-01-03/0000-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0000/-0001]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0000-02/0000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[Y-61000/-2000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2004-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2004-06-11%/2004-06~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1964/2008]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2005/2006-02]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000/0000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000-02/1111]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000-01/0000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1000/-0999]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1923-21/1924]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2019-12/2020%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984~/2004-06]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984/2004-06~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984~/2004~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1984?/2004%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-06-02?/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1952-23~/1953]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2004-06-01/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985-04-12/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985-04/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[/1985-04-12]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[/1985-04]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[/1985]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985-04-12/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985-04/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../1985-04-12]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../1985-04]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../1985]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1985-04/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1985/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2019-12/%2020]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2019-~12/2020]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000-XX/2012]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[198X/199X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[198X/1999]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1987/199X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1964/2008]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2005/2006-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000-02/1111]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000-01/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y170000002]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y-170000002]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-21]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2010]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984?]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2006%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-06?]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[201X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[19XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-XX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-20XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-02-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1000/-0999]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1923-21/1924]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2019-12/2020%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984~/2004-06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984/2004-06~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984~/2004~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1984?/2004%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-06-02?/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1952-23~/1953]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-06-01/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[/1985-04-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[/1985-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[/1985]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../1985-04-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../1985-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../1985]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y-17E7]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y17E8]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1950S2]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y171010000S3]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y3388E2S3]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1859S5]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y-171010000S2]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-26]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-27]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-28]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-29]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-31]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-32]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-33]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-34]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-35]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-36]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-37]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-38]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-39]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-40]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-41]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[1760-12..]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[..1984]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{..1984}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{1760-12..}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[%2001]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-?06-?11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?2004-06-04~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004?-06-~11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?2004-06%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004?-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2011-23~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?-2004-06%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004?-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?-2004-06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[%-2011-06-13]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1560-XX-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[156X-12-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[15XX-12-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1XXX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1XXX-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-1X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[20X0-10-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1X99-01-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-156X-12-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-15XX-12-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1XXX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1XXX-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1984-1X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2019-12/%2020]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2019-~12/2020]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[198X/199X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[198X/1999]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1987/199X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-03",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-03-",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-03-29",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[18",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-0",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1960-06-31]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[20067890%0]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[Y2006]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[-0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[Y20067890-14-10%]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[20067890%1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[+2006%]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[NONE/]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2000/12-12]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T1:10:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T10:1:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2005-07-25T10:10:10Z/2006-01-01T10:10:10Z]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[[1",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[[1667,1668,",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[[..176",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[{-1667,1668,",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[{-1667,1",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2001-21^southernHemisphere]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1985-04-12T23:20:30z]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1985-04-12t23:20:30]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T10:10:1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T10:50:10Z15]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T10:40:10Z00:62]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:40Z25:00]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:40Z00:60]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:10-05:60]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:10+02:00:30]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[-1985-04-12T23:20:30+24]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[-1985-04-12T23:20:30Z12:00]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012/2013/1234/55BULBASAUR]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012///4444]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012\\\\2013]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-24/2012-21]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-23/2012-22]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0800/-0999]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[-1000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0001/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0000-01-03/0000-01]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0000/-0001]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0000-02/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[Y-61000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-06-11%/2004-06~]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1964/2008]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2005/2006-02]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000/0000]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000-02/1111]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000-01/0000]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y170000002]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-21]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-23]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2010]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984?]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2006%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-06?]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[201X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[19XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-20XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1000/-0999]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1923-21/1924]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2019-12/2020%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984~/2004-06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984/2004-06~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984~/2004~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1984?/2004%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-06-02?/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1952-23~/1953]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-06-01/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04-12/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[/1985-04-12]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[/1985-04]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[/1985]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../1985-04-12]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../1985-04]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../1985]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y-17E7]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y17E8]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1950S2]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y171010000S3]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y3388E2S3]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1859S5]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y-171010000S2]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-26]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-27]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-28]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-29]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-31]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-32]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-33]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-34]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-35]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-36]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-37]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-38]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-39]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-40]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-41]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[1760-12..]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[..1984]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{..1984}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{1760-12..}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[%2001]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-?06-?11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?2004-06%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004?-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2011-23~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?-2004-06%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004?-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?-2004-06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[%-2011-06-13]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1560-XX-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1XXX-12]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-1X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[20X0-10-02]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1X99-01-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-156X-12-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1XXX-12]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1984-1X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2019-12/%2020]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2019-~12/2020]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000-XX/2012]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[198X/199X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[198X/1999]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1987/199X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[Y170000002]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2001-21]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-23]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2010]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2006%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[201X]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[19XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-20XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1000/-0999]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1923-21/1924]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2019-12/2020%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~/2004-06]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984/2004-06~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~/2004~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1984?/2004%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06-02?/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1952-23~/1953]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06-01/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04-12/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/1985-04-12]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/1985-04]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/1985]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../1985-04-12]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../1985-04]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../1985]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985/]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1964/2008]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2005/2006-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000/0000]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000-02/1111]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000-01/0000]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y-17E7]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y17E8]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1950S2]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y171010000S3]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y3388E2S3]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1859S5]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y-171010000S2]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-26]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-27]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-28]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-29]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-31]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-32]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-33]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-34]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-35]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-36]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-37]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-38]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-39]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-40]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-41]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[1760-12..]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[..1984]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{..1984}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{1760-12..}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[%2001]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-?06-?11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?2004-06%]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004?-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2011-23~]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2004-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?-2004-06%]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2004?-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?-2004-06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[%-2011-06-13]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1560-XX-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1XXX-12]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-1X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[20X0-10-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1X99-01-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-156X-12-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1XXX-12]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1984-1X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2019-12/%2020]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2019-~12/2020]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000-XX/2012]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[198X/199X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[198X/1999]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1987/199X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y-17E7]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y17E8]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1950S2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y171010000S3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y3388E2S3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1859S5]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y-171010000S2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-26]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-27]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-28]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-29]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-30]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-31]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-32]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-33]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-34]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-35]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-36]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-37]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-38]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-39]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-40]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-41]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1760-12..]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[..1984]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{..1984}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{1760-12..}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[%2001]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-?06-?11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2011-23~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[%-2011-06-13]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1560-XX-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1XXX-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-1X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[20X0-10-02]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1X99-01-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-156X-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1XXX-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1984-1X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2019-12/%2020]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2019-~12/2020]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000-XX/2012]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[198X/199X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[198X/1999]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1987/199X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1964/2008]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2005/2006-02]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000/0000]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000-02/1111]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000-01/0000]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[Y170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2001-21]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-23]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2010]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984?]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2006%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-06?]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[201X]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[19XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-20XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1000/-0999]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1923-21/1924]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2019-12/2020%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984~/2004-06]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984/2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984~/2004~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1984?/2004%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984-06-02?/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1952-23~/1953]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-06-01/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[/1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[/1985-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[/1985]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../1985-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../1985]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1964/2008]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2005/2006-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000/0000]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000-02/1111]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000-01/0000]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y170000002]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y-170000002]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-21]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-23]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2010]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984?]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2006%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-06?]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[201X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[19XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-20XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-02-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1000/-0999]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1923-21/1924]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2019-12/2020%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984~/2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984~/2004~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1984?/2004%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-06-02?/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1952-23~/1953]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-06-01/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04-12/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[/1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[/1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[/1985]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../1985]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y-17E7]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y17E8]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1950S2]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y171010000S3]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1859S5]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y-171010000S2]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-26]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-27]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-28]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-29]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-31]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-32]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-33]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-34]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-35]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-36]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-37]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-38]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-39]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-40]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-41]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[..1984]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{..1984}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{1760-12..}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[%2001]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-?06-?11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2011-23~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?-2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?-2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[%-2011-06-13]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1560-XX-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[20X0-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1X99-01-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2019-12/%2020]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2019-~12/2020]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[198X/199X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[198X/1999]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1987/199X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1964/2008]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2005/2006-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000/0000]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000-02/1111]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000-01/0000]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[Y170000002]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[Y-170000002]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2001-21]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-23]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2010]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984?]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2006%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-06?]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[201X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[19XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-20XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2001-02-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1000/-0999]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1923-21/1924]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2019-12/2020%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984~/2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984~/2004~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1984?/2004%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984-06-02?/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1952-23~/1953]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-06-01/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[/1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[/1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[/1985]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../1985]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y-17E7]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y17E8]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1950S2]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y171010000S3]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1859S5]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y-171010000S2]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-26]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-27]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-28]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-29]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-31]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-32]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-33]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-34]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-35]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-36]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-37]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-38]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-39]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-40]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-41]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[..1984]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{..1984}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{1760-12..}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[%2001]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-?06-?11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2011-23~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?-2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?-2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[%-2011-06-13]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1560-XX-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[20X0-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1X99-01-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2019-12/%2020]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2019-~12/2020]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[198X/199X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[198X/1999]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1987/199X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1964/2008]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2005/2006-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000/0000]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000-02/1111]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000-01/0000]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y170000002]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y-170000002]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-21]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-23]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2010]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984?]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2006%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-06?]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[201X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[19XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-20XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-02-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1000/-0999]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1923-21/1924]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2019-12/2020%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984~/2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984~/2004~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1984?/2004%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-06-02?/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1952-23~/1953]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-06-01/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[/1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[/1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[/1985]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../1985]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y-17E7]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y17E8]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1950S2]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y171010000S3]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1859S5]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y-171010000S2]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-26]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-27]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-28]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-29]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-31]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-32]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-33]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-34]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-35]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-36]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-37]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-38]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-39]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-40]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-41]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[..1984]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{..1984}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{1760-12..}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[%2001]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-?06-?11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2011-23~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?-2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?-2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[%-2011-06-13]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1560-XX-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[20X0-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1X99-01-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2019-12/%2020]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2019-~12/2020]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[198X/199X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[198X/1999]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1987/199X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-03",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-03-",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-03-29",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[18",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-0",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1960-06-31]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[20067890%0]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[Y2006]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[-0000]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[Y20067890-14-10%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[20067890%1]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[+2006%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[NONE/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2000/12-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2012-10-10T1:10:10]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2012-10-10T10:1:10]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2005-07-25T10:10:10Z/2006-01-01T10:10:10Z]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[[1",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[[1667,1668,",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[[..176",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[{-1667,1668,",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[{-1667,1",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2001-21^southernHemisphere]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[]"
]
| {
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false
} | 2020-08-03 20:07:48+00:00 | bsd-3-clause | 6,171 |
|
unt-libraries__edtf-validate-30 | diff --git a/edtf_validate/valid_edtf.py b/edtf_validate/valid_edtf.py
index 53dd491..e7f73d5 100644
--- a/edtf_validate/valid_edtf.py
+++ b/edtf_validate/valid_edtf.py
@@ -465,9 +465,15 @@ def is_valid_interval(edtf_candidate):
return zero_year_special_case(parts[0], parts[1], start, end)
# 2 '-' characters means we are matching year-month-day
if parts[0].count("-") == 2:
- from_date = datetime.datetime.strptime(parts[0], "%Y-%m-%d")
+ try:
+ from_date = datetime.datetime.strptime(parts[0], "%Y-%m-%d")
+ except ValueError:
+ return False
if parts[1].count("-") == 2:
- to_date = datetime.datetime.strptime(parts[1], "%Y-%m-%d")
+ try:
+ to_date = datetime.datetime.strptime(parts[1], "%Y-%m-%d")
+ except ValueError:
+ return False
# handle special case of same year season/season range due to
# the overlap of the months we are designating for the seasons
if parts[0].count("-") == 1 and parts[1].count("-") == 1:
| unt-libraries/edtf-validate | f67d495a81d8bd1e7530ee6b68504180dc81c96f | diff --git a/tests/test_valid_edtf.py b/tests/test_valid_edtf.py
index b74d118..90876a2 100644
--- a/tests/test_valid_edtf.py
+++ b/tests/test_valid_edtf.py
@@ -272,6 +272,9 @@ invalid_edtf_intervals = [
'Y-61000/-2000',
'2004-06-11%/2004-%06',
'2004-06-11%/2004-06~',
+ '2005-07-25T10:10:10Z/2006-01-01T10:10:10Z',
+ '2005-07-25T10:10:10Z/2006-01',
+ '2005-07-25/2006-01-01T10:10:10Z',
]
invalid_edtf_datetimes = [
| Handle `ValueError` in `is_valid_interval`
If you call `is_valid_interval` with a string that contains a date with a time component, you get a `ValueError` such as in:
```
>>> is_valid_interval('1985-04-12T23:20:30/1990-02-10T23:12:30')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "edtf-validate/edtf_validate/valid_edtf.py", line 468, in is_valid_interval
from_date = datetime.datetime.strptime(parts[0], "%Y-%m-%d")
File "python3.7/_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/opt/lib/python3.7/_strptime.py", line 362, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: T23:20:30
```
We should catch this type of error both in converting the "to" and "from" date and return that it is an invalid interval. | 0.0 | f67d495a81d8bd1e7530ee6b68504180dc81c96f | [
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2005-07-25T10:10:10Z/2006-01-01T10:10:10Z]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2005-07-25T10:10:10Z/2006-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2005-07-25/2006-01-01T10:10:10Z]"
]
| [
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012/2013/1234/55BULBASAUR]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012///4444]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012\\\\2013]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012-24/2012-21]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2012-23/2012-22]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0800/-0999]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[-1000/-2000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[1000/-2000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0001/0000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0000-01-03/0000-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0000/-0001]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[0000-02/0000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[Y-61000/-2000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2004-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_interval_malformed[2004-06-11%/2004-06~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1964/2008]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2005/2006-02]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000/0000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000-02/1111]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0000-01/0000]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1000/-0999]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1923-21/1924]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2019-12/2020%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984~/2004-06]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984/2004-06~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984~/2004~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1984?/2004%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-06-02?/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1952-23~/1953]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2004-06-01/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985-04-12/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985-04/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[/1985-04-12]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[/1985-04]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[/1985]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985-04-12/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985-04/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1985/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../1985-04-12]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../1985-04]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../1985]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[../..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1985-04/..]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1985/]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2019-12/%2020]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2019-~12/2020]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000-XX/2012]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[198X/199X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[198X/1999]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1987/199X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestIsValidInterval::test_valid_intervals[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1964/2008]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2005/2006-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000-02/1111]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0000-01/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y170000002]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y-170000002]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-21]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2010]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984?]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2006%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-06?]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[201X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[19XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-XX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-20XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-02-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1000/-0999]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1923-21/1924]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2019-12/2020%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984~/2004-06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984/2004-06~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984~/2004~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1984?/2004%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-06-02?/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1952-23~/1953]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-06-01/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[/1985-04-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[/1985-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[/1985]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04-12/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985-04/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1985/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../1985-04-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../1985-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../1985]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[../..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985-04/..]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1985/]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y-17E7]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y17E8]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1950S2]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y171010000S3]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y3388E2S3]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1859S5]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y-171010000S2]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-26]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-27]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-28]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-29]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-31]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-32]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2001-33]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-34]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-35]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-36]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-37]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-38]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-39]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-40]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2001-41]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[1760-12..]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[[..1984]]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{..1984}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[{1760-12..}]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[%2001]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-?06-?11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?2004-06-04~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004?-06-~11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?2004-06%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004?-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2011-23~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?-2004-06%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004?-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?-2004-06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[%-2011-06-13]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1560-XX-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[156X-12-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[15XX-12-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1XXX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1XXX-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-1X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[20X0-10-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1X99-01-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-156X-12-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-15XX-12-25]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1XXX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1XXX-12]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1984-1X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2019-12/%2020]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2019-~12/2020]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000-XX/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[198X/199X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[198X/1999]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1987/199X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestIsValid::test_valid_edtf_all[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-03",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-03-",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-03-29",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[18",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1863-0",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1960-06-31]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[20067890%0]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[Y2006]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[-0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[Y20067890-14-10%]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[20067890%1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[+2006%]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[NONE/]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2000/12-12]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T1:10:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T10:1:10]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2005-07-25T10:10:10Z/2006-01-01T10:10:10Z0]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[[1",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[[1667,1668,",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[[..176",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[{-1667,1668,",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[{-1667,1",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2001-21^southernHemisphere]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1985-04-12T23:20:30z]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1985-04-12t23:20:30]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T10:10:1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T10:50:10Z15]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-10-10T10:40:10Z00:62]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:40Z25:00]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:40Z00:60]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:10-05:60]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:10+02:00:30]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-01-01T10:10:1000:59]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[-1985-04-12T23:20:30+24]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[-1985-04-12T23:20:30Z12:00]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012/2013/1234/55BULBASAUR]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012///4444]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012\\\\2013]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-24/2012-21]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2012-23/2012-22]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0800/-0999]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[-1000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[1000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0001/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0000-01-03/0000-01]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0000/-0001]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[0000-02/0000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[Y-61000/-2000]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2004-06-11%/2004-06~]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2005-07-25T10:10:10Z/2006-01-01T10:10:10Z1]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2005-07-25T10:10:10Z/2006-01]",
"tests/test_valid_edtf.py::TestIsValid::test_invalid_edtf_all[2005-07-25/2006-01-01T10:10:10Z]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1964/2008]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[2005/2006-02]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000/0000]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000-02/1111]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestLevel0::test_valid_level_0[0000-01/0000]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y170000002]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-21]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-23]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2010]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984?]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2006%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-06?]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[201X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[19XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-20XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1000/-0999]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1923-21/1924]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2019-12/2020%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984~/2004-06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984/2004-06~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984~/2004~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1984?/2004%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-06-02?/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1952-23~/1953]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-06-01/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04-12/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[/1985-04-12]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[/1985-04]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[/1985]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985-04/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1985/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../1985-04-12]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../1985-04]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../1985]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[../..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985-04/..]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1985/]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y-17E7]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y17E8]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1950S2]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y171010000S3]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y3388E2S3]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1859S5]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y-171010000S2]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-26]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-27]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-28]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-29]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-31]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-32]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2001-33]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-34]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-35]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-36]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-37]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-38]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-39]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-40]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2001-41]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[1760-12..]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[[..1984]]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{..1984}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[{1760-12..}]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[%2001]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-?06-?11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?2004-06%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004?-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2011-23~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?-2004-06%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004?-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?-2004-06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[%-2011-06-13]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1560-XX-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1XXX-12]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-1X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[20X0-10-02]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1X99-01-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-156X-12-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1XXX-12]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1984-1X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2019-12/%2020]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2019-~12/2020]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000-XX/2012]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[198X/199X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[198X/1999]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1987/199X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestLevel0::test_invalid_level_0[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[Y170000002]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2001-21]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-23]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2010]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2006%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[201X]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[19XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-20XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1000/-0999]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1923-21/1924]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2019-12/2020%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~/2004-06]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984/2004-06~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984~/2004~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1984?/2004%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1984-06-02?/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1952-23~/1953]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-2004-06-01/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04-12/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985/]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/1985-04-12]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/1985-04]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/1985]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985-04/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[1985/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../1985-04-12]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../1985-04]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../1985]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[../..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985-04/..]",
"tests/test_valid_edtf.py::TestLevel1::test_valid_level_1[-1985/]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1964/2008]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2005/2006-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000/0000]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000-02/1111]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0000-01/0000]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y-17E7]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y17E8]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1950S2]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y171010000S3]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y3388E2S3]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1859S5]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y-171010000S2]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-26]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-27]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-28]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-29]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-31]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-32]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2001-33]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-34]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-35]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-36]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-37]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-38]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-39]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-40]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2001-41]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[1760-12..]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[[..1984]]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{..1984}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[{1760-12..}]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[%2001]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-?06-?11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?2004-06%]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004?-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2011-23~]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2004-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?-2004-06%]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2004?-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?-2004-06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[%-2011-06-13]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1560-XX-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1XXX-12]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-1X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[20X0-10-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1X99-01-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-156X-12-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1XXX-12]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1984-1X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2019-12/%2020]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2019-~12/2020]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000-XX/2012]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[198X/199X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[198X/1999]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1987/199X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestLevel1::test_invalid_level_1[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y-17E7]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y17E8]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1950S2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y171010000S3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y3388E2S3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1859S5]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y-171010000S2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-26]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-27]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-28]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-29]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-30]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-31]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-32]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2001-33]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-34]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-35]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-36]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-37]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-38]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-39]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-40]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2001-41]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1760-12..]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[[..1984]]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{..1984}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[{1760-12..}]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[%2001]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-?06-?11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004?-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2011-23~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004?-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?-2004-06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[%-2011-06-13]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1560-XX-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[156X-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1XXX-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-1X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[20X0-10-02]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1X99-01-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-156X-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-15XX-12-25]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1XXX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1XXX-12]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1984-1X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2019-12/%2020]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2019-~12/2020]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000-XX/2012]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[198X/199X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[198X/1999]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1987/199X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestLevel2::test_valid_level_2[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1964/2008]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2005/2006-02]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000/0000]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000-02/1111]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[0000-01/0000]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[Y170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[Y-170000002]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2001-21]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-23]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2010]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984?]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2006%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-06?]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[201X]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[19XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-20XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2001-02-03]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1000/-0999]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1923-21/1924]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2019-12/2020%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984~/2004-06]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984/2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984~/2004~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1984?/2004%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1984-06-02?/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1952-23~/1953]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-2004-06-01/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985/]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[/1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[/1985-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[/1985]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985-04/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[1985/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../1985-04-12]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../1985-04]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../1985]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[../..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985-04/..]",
"tests/test_valid_edtf.py::TestLevel2::test_invalid_level_2[-1985/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1964/2008]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[2005/2006-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000/0000]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000-02/1111]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_valid_conformsLevel0[0000-01/0000]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y170000002]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y-170000002]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-21]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-23]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2010]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984?]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2006%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-06?]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[201X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[19XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-20XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-02-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1000/-0999]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1923-21/1924]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2019-12/2020%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984~/2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984~/2004~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1984?/2004%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-06-02?/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1952-23~/1953]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-06-01/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04-12/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[/1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[/1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[/1985]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1985/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../1985]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[../..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1985/]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y-17E7]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y17E8]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1950S2]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y171010000S3]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1859S5]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y-171010000S2]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-26]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-27]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-28]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-29]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-31]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-32]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2001-33]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-34]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-35]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-36]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-37]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-38]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-39]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-40]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2001-41]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[[..1984]]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{..1984}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[{1760-12..}]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[%2001]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-?06-?11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2011-23~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?-2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?-2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[%-2011-06-13]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1560-XX-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[20X0-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1X99-01-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2019-12/%2020]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2019-~12/2020]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[198X/199X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[198X/1999]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1987/199X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestConformsLevel0::test_invalid_conformsLevel0[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1964/2008]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2005/2006-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000/0000]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000-02/1111]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[0000-01/0000]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[Y170000002]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[Y-170000002]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2001-21]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-23]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2010]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984?]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2006%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-06?]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[201X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[19XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-20XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2001-02-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1000/-0999]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1923-21/1924]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2019-12/2020%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984~/2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984~/2004~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1984?/2004%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1984-06-02?/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1952-23~/1953]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-2004-06-01/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[/1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[/1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[/1985]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[1985/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../1985]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[../..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_valid_conformsLevel1[-1985/]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y-17E7]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y17E8]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1950S2]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y171010000S3]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1859S5]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y-171010000S2]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-26]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-27]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-28]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-29]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-31]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-32]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2001-33]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-34]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-35]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-36]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-37]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-38]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-39]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-40]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2001-41]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[[..1984]]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{..1984}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[{1760-12..}]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[%2001]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-?06-?11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2011-23~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?-2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?-2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[%-2011-06-13]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1560-XX-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[20X0-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1X99-01-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2019-12/%2020]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2019-~12/2020]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[198X/199X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[198X/1999]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1987/199X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestConformsLevel1::test_invalid_conformsLevel1[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-01-01T10:10:10+00:59]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1964/2008]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06/2006-08]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-02-01/2005-02-08]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-02-01/2005-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2005/2006-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000/0000]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000-02/1111]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000-01/0000-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000-01-13/0000-01-23]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1111-01-01/1111]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0000-01/0000]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y170000002]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y-170000002]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-21]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-23]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2010]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984?]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2006%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-06?]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[201X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[19XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-20XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12T23:20:30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12T23:20:30Z]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12T23:20:30-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12T23:20:30+04:30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-02-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1000/-0999]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-02-01/2005]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1980-11-01/1989-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1923-21/1924]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2019-12/2020%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984~/2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984~/2004~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1984?/2004%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984?/2004-06~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-06?/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-06-02?/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06~/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-06-02?/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1952-23~/1953]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-06-01/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[/1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[/1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[/1985]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-22/2004-22]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-22/2003-22]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-22/2003-23]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1985/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../1985-04-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../1985-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../1985]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[../..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04-12/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985-04/..]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1985/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y-17E7]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y17E8]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1950S2]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y171010000S3]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1859S5]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y-171010000S2]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[Y-3388E2S3]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-26]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-27]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-28]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-29]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-31]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-32]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2001-33]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-34]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-35]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-36]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-37]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-38]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-39]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-40]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2001-41]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[-1667,1668,1670..1672]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[..1760-12-03]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[1760-01,-1760-02,1760-12..]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[-1740-02-12..-1200-01-29]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[-1890-05..-1200-01]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[-1667,1760-12]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[[..1984]]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{-1667,1668,1670..1672}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{1960,-1961-12}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{-1640-06..-1200-01}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{-1740-02-12..-1200-01-29}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{..1984}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[{1760-12..}]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[%2001]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-?06-?11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2011-23~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?-2004-06-04~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004?-06-~11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?-2004-06%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004?-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?-2004-06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[%-2011-06-13]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1560-XX-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1X32-X1-X2]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[20X0-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1X99-01-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-156X-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-15XX-12-25]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-XXXX-12-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1XXX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1XXX-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1984-1X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06-~01/2004-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2004-06-?01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2005-06-%01/2006-06-~20]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2019-12/%2020]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984?-06/2004-08?]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-1984-?06-02/2004-08-08~]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-?06-02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2019-~12/2020]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-06-11%/2004-%06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06~/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984?/2004~-06]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[?2004-06~-10/2004-06-%11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2004-06-XX/2004-07-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2003-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[20X3-06-25/2004-X1-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[XXXX-12-21/1890-09-2X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-11-2X/1999-01-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-11-12/1984-11-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[198X-11-XX/198X-11-30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2000-12-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000-XX/2012]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000-XX-XX/2012_0]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000-XX-XX/2012_1]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2000-XX-10/2012]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2000/2000-XX-XX]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[198X/199X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[198X/1999]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1987/199X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-XX-02/1919-XX-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-0X-02/1919-01-03]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1865-X2-02/1865-03-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1930-X0-10/1930-10-30]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1981-1X-10/1981-11-09]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-12-02/1919-XX-04]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-11-02/1919-1X-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-09-02/1919-X0-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-08-02/1919-0X-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-10-02/1919-X1-01]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-04-01/1919-X4-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1602-10-0X/1602-10-02]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[-2018-05-X0/2018-05-11]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1200-01-X4/1200-01-08]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1919-07-30/1919-07-3X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1908-05-02/1908-05-0X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[0501-11-18/0501-11-1X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1112-08-22/1112-08-2X]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2015-02-27/2015-02-X8]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[2016-02-28/2016-02-X9]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_valid_conformsLevel2[1984-06-?02/2004-06-11%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-03",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-03-",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-03-29",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[18",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1863-0",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[1960-06-31]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[20067890%0]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[Y2006]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[-0000]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[Y20067890-14-10%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[20067890%1]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[+2006%]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[NONE/]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2000/12-12]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2012-10-10T1:10:10]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2012-10-10T10:1:10]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2005-07-25T10:10:10Z/2006-01-01T10:10:10Z]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[[1",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[[1667,1668,",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[[..176",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[{-1667,1668,",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[{-1667,1",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[2001-21^southernHemisphere]",
"tests/test_valid_edtf.py::TestConformsLevel2::test_invalid_conformsLevel2[]"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2020-08-03 21:22:47+00:00 | bsd-3-clause | 6,172 |
|
unt-libraries__py-wasapi-client-18 | diff --git a/wasapi_client.py b/wasapi_client.py
index 5b1ea4e..0336263 100755
--- a/wasapi_client.py
+++ b/wasapi_client.py
@@ -19,16 +19,15 @@ except:
from queue import Empty
from urllib.parse import urlencode
+NAME = 'wasapi_client' if __name__ == '__main__' else __name__
-NAME = 'wasapi-client' if __name__ == '__main__' else __name__
-
-MAIN_LOGGER = logging.getLogger('main')
+LOGGER = logging.getLogger(NAME)
READ_LIMIT = 1024 * 512
-def do_listener_logging(log_q, path=''):
- formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
+def start_listener_logging(log_q, path=''):
+ formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s')
if path:
handler = logging.FileHandler(filename=path)
else:
@@ -39,16 +38,27 @@ def do_listener_logging(log_q, path=''):
listener = logging.handlers.QueueListener(log_q, handler)
listener.start()
- # Add the handler to the logger, so records from this process are written.
- logger = logging.getLogger(NAME)
- logger.addHandler(handler)
return listener
-def configure_worker_logging(log_q, log_level=logging.ERROR, logger_name=None):
- logger = logging.getLogger(logger_name)
- logger.setLevel(log_level)
- logger.addHandler(logging.handlers.QueueHandler(log_q))
+def configure_main_logging(log_q, log_level=logging.ERROR):
+ """Put a handler on the root logger.
+
+ This allows handling log records from imported modules.
+ """
+ root = logging.getLogger()
+ root.addHandler(logging.handlers.QueueHandler(log_q))
+ root.setLevel(log_level)
+
+
+def configure_worker_logging(log_q, log_level=logging.ERROR):
+ """Configure logging for worker processes."""
+ # Remove any existing handlers.
+ LOGGER.handlers = []
+ # Prevent root logger duplicating messages.
+ LOGGER.propagate = False
+ LOGGER.addHandler(logging.handlers.QueueHandler(log_q))
+ LOGGER.setLevel(log_level)
class WASAPIDownloadError(Exception):
@@ -75,7 +85,7 @@ def get_webdata(webdata_uri, session):
response = session.get(webdata_uri)
except requests.exceptions.ConnectionError as err:
sys.exit('Could not connect at {}:\n{}'.format(webdata_uri, err))
- MAIN_LOGGER.info('requesting {}'.format(webdata_uri))
+ LOGGER.info('requesting {}'.format(webdata_uri))
if response.status_code == 403:
sys.exit('Verify user/password for {}:\n{} {}'.format(webdata_uri,
response.status_code,
@@ -188,13 +198,13 @@ def download_file(file_data, session, output_path):
try:
write_file(response, output_path)
except OSError as err:
- logging.error('{}: {}'.format(location, str(err)))
+ LOGGER.error('{}: {}'.format(location, str(err)))
break
# Successful download; don't try alternate locations.
- logging.info(msg)
+ LOGGER.info(msg)
return None
else:
- logging.error(msg)
+ LOGGER.error(msg)
# We didn't download successfully; raise error.
msg = 'FAILED to download {} from {}'.format(file_data['filename'],
file_data['locations'])
@@ -219,17 +229,17 @@ def verify_file(checksums, file_path):
hash_function = getattr(hashlib, algorithm, None)
if not hash_function:
# The hash algorithm provided is not supported by hashlib.
- logging.debug('{} is unsupported'.format(algorithm))
+ LOGGER.debug('{} is unsupported'.format(algorithm))
continue
digest = calculate_sum(hash_function, file_path)
if digest == value:
- logging.info('Checksum success at: {}'.format(file_path))
+ LOGGER.info('Checksum success at: {}'.format(file_path))
return True
else:
- logging.error('Checksum {} mismatch for {}: expected {}, got {}'.format(algorithm,
- file_path,
- value,
- digest))
+ LOGGER.error('Checksum {} mismatch for {}: expected {}, got {}'.format(algorithm,
+ file_path,
+ value,
+ digest))
return False
# We didn't find a compatible algorithm.
return False
@@ -312,7 +322,7 @@ class Downloader(multiprocessing.Process):
try:
download_file(file_data, self.session, output_path)
except WASAPIDownloadError as err:
- logging.error(str(err))
+ LOGGER.error(str(err))
else:
# If we download the file without error, verify the checksum.
if verify_file(file_data['checksums'], output_path):
@@ -365,7 +375,7 @@ def _parse_args(args=sys.argv[1:]):
action='store_true',
dest='skip_manifest',
help='do not generate checksum files (ignored'
- ' when used in combination with --manifest')
+ ' when used in combination with --manifest)')
parser.add_argument('-u',
'--user',
dest='user',
@@ -443,7 +453,7 @@ def main():
manager = multiprocessing.Manager()
log_q = manager.Queue()
try:
- listener = do_listener_logging(log_q, args.log)
+ listener = start_listener_logging(log_q, args.log)
except OSError as err:
print('Could not open file for logging:', err)
sys.exit(1)
@@ -453,7 +463,7 @@ def main():
log_level = [logging.ERROR, logging.INFO, logging.DEBUG][args.verbose]
except IndexError:
log_level = logging.DEBUG
- configure_worker_logging(log_q, log_level, 'main')
+ configure_main_logging(log_q, log_level)
# Generate query string for the webdata request.
try:
@@ -499,8 +509,15 @@ def main():
destination=args.destination)
get_q = downloads.get_q
result_q = manager.Queue()
- for _ in range(args.processes):
- Downloader(get_q, result_q, log_q, log_level, auth, args.destination).start()
+
+ download_processes = []
+ num_processes = min(args.processes, get_q.qsize())
+ for _ in range(num_processes):
+ dp = Downloader(get_q, result_q, log_q, log_level, auth, args.destination)
+ dp.start()
+ download_processes.append(dp)
+ for dp in download_processes:
+ dp.join()
get_q.join()
listener.stop()
| unt-libraries/py-wasapi-client | 509c7dcac70c7e9ef03a2fac10dc2c5d6479cbb8 | diff --git a/tests/test_wasapi_client.py b/tests/test_wasapi_client.py
index 2424886..9ff5c7f 100644
--- a/tests/test_wasapi_client.py
+++ b/tests/test_wasapi_client.py
@@ -385,13 +385,13 @@ class Test_verify_file:
path = 'dummy/path'
checksums = {algorithm: checksum}
mock_calc_sum.return_value = checksum + 'notmatching'
- with patch('wasapi_client.logging', autospec=True) as mock_logging:
+ with patch('wasapi_client.LOGGER', autospec=True) as mock_logger:
assert not wc.verify_file(checksums, path)
msg = 'Checksum {} mismatch for {}: expected {}, got {}notmatching'.format(algorithm,
path,
checksum,
checksum)
- mock_logging.error.assert_called_once_with(msg)
+ mock_logger.error.assert_called_once_with(msg)
@patch('wasapi_client.calculate_sum')
def test_verify_file_one_supported_algorithm(self, mock_calc_sum):
@@ -400,11 +400,11 @@ class Test_verify_file:
checksums = OrderedDict([('abc', 'algorithm_unsupported'),
('sha1', checksum)])
mock_calc_sum.return_value = checksum
- with patch('wasapi_client.logging', autospec=True) as mock_logging:
+ with patch('wasapi_client.LOGGER', autospec=True) as mock_logger:
assert wc.verify_file(checksums, 'dummy/path')
# Check that unsupported algorithm was tried.
- mock_logging.debug.assert_called_once_with('abc is unsupported')
- mock_logging.info.assert_called_once_with('Checksum success at: dummy/path')
+ mock_logger.debug.assert_called_once_with('abc is unsupported')
+ mock_logger.info.assert_called_once_with('Checksum success at: dummy/path')
class Test_calculate_sum:
| Duplicate logging messages
The same messages are being logged multiple times--at least with more than one download process running. | 0.0 | 509c7dcac70c7e9ef03a2fac10dc2c5d6479cbb8 | [
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_checksum_mismatch",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_one_supported_algorithm"
]
| [
"tests/test_wasapi_client.py::Test_make_session::test_make_session_auth",
"tests/test_wasapi_client.py::Test_make_session::test_make_session_no_auth",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_403_forbidden",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_ConnectionError",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_json_error",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_multi_page",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_no_get_q",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_urls",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_manifest",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_manifest_destination",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_generate_manifest",
"tests/test_wasapi_client.py::Test_Downloads::test_write_manifest_file",
"tests/test_wasapi_client.py::Test_Downloads::test_write_manifest_file_wrong_algorithm",
"tests/test_wasapi_client.py::Test_get_files_count::test_get_files_count",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size_multi_page",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size_no_files",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[0-0.0B]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1023-1023.0B]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1024-1.0KB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1024000-1000.0KB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1048576-1.0MB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1073741824-1.0GB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1099511628000-1.0TB]",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_200",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_not_200",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_OSError",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_unsupported_algorithm",
"tests/test_wasapi_client.py::Test_calculate_sum::test_calculate_sum",
"tests/test_wasapi_client.py::Test_convert_queue::test_convert_queue",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_all_success",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_one_failure",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_all_failure",
"tests/test_wasapi_client.py::TestDownloader::test_run",
"tests/test_wasapi_client.py::TestDownloader::test_run_WASAPIDownloadError",
"tests/test_wasapi_client.py::Test_parse_args::test_SetQueryParametersAction",
"tests/test_wasapi_client.py::Test_parse_args::test_SetQueryParametersAction_multiple_collections"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2017-09-28 20:42:05+00:00 | bsd-3-clause | 6,173 |
|
unt-libraries__py-wasapi-client-29 | diff --git a/.travis.yml b/.travis.yml
index 5339b5e..d856516 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,9 +1,11 @@
+dist: xenial
language: python
sudo: false
python:
- "3.4"
- "3.5"
- "3.6"
+ - "3.7"
install:
- pip install -r requirements-test.txt
- pip install flake8
diff --git a/tox.ini b/tox.ini
index f9a6310..0ab10bc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,7 +2,7 @@
max-line-length = 99
[tox]
-envlist = py34,py35,py36,flake8
+envlist = py34,py35,py36,py37,flake8
[testenv]
usedevelop=True
diff --git a/wasapi_client.py b/wasapi_client.py
index 29b7167..dbb7509 100755
--- a/wasapi_client.py
+++ b/wasapi_client.py
@@ -97,7 +97,7 @@ def get_webdata(webdata_uri, session):
try:
return response.json()
except (JSONDecodeError, ValueError) as err:
- sys.exit('Non-JSON response from {}'.format(webdata_uri))
+ sys.exit('Non-JSON response from {}:\n{}'.format(webdata_uri, err))
def get_files_count(webdata_uri, auth=None):
@@ -216,7 +216,13 @@ def download_file(data_file, session, output_path):
data_file.verified = True
return data_file
for location in data_file.locations:
- response = session.get(location, stream=True)
+ try:
+ response = session.get(location, stream=True)
+ except requests.exceptions.RequestException as err:
+ # This could be a remote disconnect, read timeout, connection timeout,
+ # temporary name resolution issue...
+ LOGGER.error('Error downloading {}:\n{}'.format(location, err))
+ continue
msg = '{}: {} {}'.format(location,
response.status_code,
response.reason)
| unt-libraries/py-wasapi-client | a39188e49aced9d33e134fc41a0850a804bc6d51 | diff --git a/requirements-test.txt b/requirements-test.txt
index 45fc928..4cdb0e8 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,2 +1,2 @@
requests>=2.18.1
-pytest==3.2.1
+pytest>=4.6.4
diff --git a/tests/test_wasapi_client.py b/tests/test_wasapi_client.py
index f152c89..bc1e3e9 100644
--- a/tests/test_wasapi_client.py
+++ b/tests/test_wasapi_client.py
@@ -7,6 +7,7 @@ import multiprocessing
import os
import sys
from collections import OrderedDict
+from logging import INFO
from unittest.mock import call, mock_open, patch
import pytest
@@ -331,14 +332,36 @@ class Test_download_file:
with patch.object(session, 'get', return_value=mock_403) as mock_get, \
pytest.raises(wc.WASAPIDownloadError) as err:
wc.download_file(self.data_file, session, self.filename)
-
for item in (str(self.locations), self.filename):
- assert item in str(err)
+ assert item in err.value.args[0]
# Check all locations were tried.
calls = [call(self.locations[0], stream=True),
call(self.locations[1], stream=True)]
mock_get.assert_has_calls(calls)
+ def test_download_get_raises_some_RequestException(self, caplog):
+ caplog.set_level(INFO)
+ session = requests.Session()
+ mock_200 = MockResponse200('')
+
+ with patch.object(session, 'get') as mock_get, \
+ patch('wasapi_client.write_file') as mock_write_file:
+ # Raise a subclass of RequestException on first download attempt;
+ # mock a successful response on the second attempt
+ mock_get.side_effect = [requests.exceptions.ConnectionError(),
+ mock_200]
+ wc.download_file(self.data_file, session, self.filename)
+
+ # Check all locations were tried.
+ calls = [call(self.locations[0], stream=True),
+ call(self.locations[1], stream=True)]
+ mock_get.assert_has_calls(calls)
+ mock_write_file.assert_called_once_with(mock_200, self.filename)
+ # Verify requests exception was caught and logged.
+ for msg in ('Error downloading http://loc1/blah.warc.gz:',
+ 'http://loc2/blah.warc.gz: 200 OK'):
+ assert msg in caplog.text
+
def test_download_file_OSError(self):
session = requests.Session()
mock_200 = MockResponse200('')
@@ -350,7 +373,7 @@ class Test_download_file:
wc.download_file(self.data_file, session, self.filename)
for item in (str(self.locations), self.filename):
- assert item in str(err)
+ assert item in err.value.args[0]
# Check we only tried downloading files until successful download.
mock_get.assert_called_once_with(self.locations[0], stream=True)
mock_write_file.assert_called_once_with(mock_200, self.filename)
| Handle RemoteDisconnected
Trying to download a collection of ~7,000 WARCs will error and hang after downloading ~100 WARCs. Command executed:
`wasapi-client --collection 418 -u 'xxxxxxxx' -vv --log /somedir/mi_418_out.log.14 -p 1 -d /somedir/mi_418/`
```
Process Downloader-2:
Traceback (most recent call last):
File "/home/user/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/user/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/home/user/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib64/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib64/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/.local/lib/python3.6/site-packages/requests/adapters.py", line 449, in send
timeout=timeout
File "/home/user/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/user/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 368, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/user/.local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/user/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/user/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/home/user/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib64/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib64/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python3.6/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/user/.local/bin/wasapi_client.py", line 352, in run
data_file = download_file(data_file, self.session, output_path)
File "/home/user/.local/bin/wasapi_client.py", line 219, in download_file
response = session.get(location, stream=True)
File "/home/user/.local/lib/python3.6/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/home/user/.local/lib/python3.6/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/home/user/.local/lib/python3.6/site-packages/requests/sessions.py", line 668, in send
history = [resp for resp in gen] if allow_redirects else []
File "/home/user/.local/lib/python3.6/site-packages/requests/sessions.py", line 668, in <listcomp>
history = [resp for resp in gen] if allow_redirects else []
File "/home/user/.local/lib/python3.6/site-packages/requests/sessions.py", line 247, in resolve_redirects
**adapter_kwargs
File "/home/user/.local/lib/python3.6/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/home/user/.local/lib/python3.6/site-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
``` | 0.0 | a39188e49aced9d33e134fc41a0850a804bc6d51 | [
"tests/test_wasapi_client.py::Test_download_file::test_download_get_raises_some_RequestException"
]
| [
"tests/test_wasapi_client.py::Test_make_session::test_make_session_auth",
"tests/test_wasapi_client.py::Test_make_session::test_make_session_no_auth",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_403_forbidden",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_ConnectionError",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_json_error",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_multi_page",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_no_get_q",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_urls",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_manifest",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_manifest_destination",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_generate_manifest",
"tests/test_wasapi_client.py::Test_Downloads::test_write_manifest_file",
"tests/test_wasapi_client.py::Test_Downloads::test_write_manifest_file_wrong_algorithm",
"tests/test_wasapi_client.py::Test_get_files_count::test_get_files_count",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size_multi_page",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size_no_files",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[0-0.0B]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1023-1023.0B]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1024-1.0KB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1024000-1000.0KB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1048576-1.0MB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1073741824-1.0GB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1099511628000-1.0TB]",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_200",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_not_200",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_OSError",
"tests/test_wasapi_client.py::Test_download_file::test_download_check_exists_true",
"tests/test_wasapi_client.py::Test_check_exists::test_check_exists_return_true",
"tests/test_wasapi_client.py::Test_check_exists::test_check_exists_no_file",
"tests/test_wasapi_client.py::Test_check_exists::test_check_exists_file_size_mismatch",
"tests/test_wasapi_client.py::Test_check_exists::test_check_exists_checksum_fail",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_unsupported_algorithm",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_checksum_mismatch",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_one_supported_algorithm",
"tests/test_wasapi_client.py::Test_calculate_sum::test_calculate_sum",
"tests/test_wasapi_client.py::Test_convert_queue::test_convert_queue",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_all_success",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_one_failure",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_all_failure",
"tests/test_wasapi_client.py::TestDownloader::test_run",
"tests/test_wasapi_client.py::TestDownloader::test_run_WASAPIDownloadError",
"tests/test_wasapi_client.py::TestDownloader::test_run_file_already_verified",
"tests/test_wasapi_client.py::Test_parse_args::test_default_processes",
"tests/test_wasapi_client.py::Test_parse_args::test_SetQueryParametersAction",
"tests/test_wasapi_client.py::Test_parse_args::test_SetQueryParametersAction_multiple_collections",
"tests/test_wasapi_client.py::Test_get_credentials_env::test_get_credentials_env",
"tests/test_wasapi_client.py::Test_get_credentials_env::test_get_credentials_env_missing_one_env_var",
"tests/test_wasapi_client.py::Test_get_credentials_config::test_get_credentials_config",
"tests/test_wasapi_client.py::Test_get_credentials_config::test_get_credentials_config_missing_profile",
"tests/test_wasapi_client.py::Test_get_credentials_config::test_get_credentials_config_missing_password",
"tests/test_wasapi_client.py::Test_get_credentials::test_get_credentials_from_getpass",
"tests/test_wasapi_client.py::Test_get_credentials::test_get_credentials_from_env",
"tests/test_wasapi_client.py::Test_get_credentials::test_get_credentials_from_config",
"tests/test_wasapi_client.py::Test_get_credentials::test_get_credentials_no_credentials_provided"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2019-07-01 17:34:53+00:00 | bsd-3-clause | 6,174 |
|
unt-libraries__py-wasapi-client-31 | diff --git a/README.md b/README.md
index 08df1b7..726129c 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ That gives you usage instructions:
```
usage: wasapi-client [-h] [-b BASE_URI] [-d DESTINATION] [-l LOG] [-n] [-v]
- [--profile PROFILE | -u USER]
+ [--profile PROFILE | -u USER | -t TOKEN]
[-c | -m | -p PROCESSES | -s | -r]
[--collection COLLECTION [COLLECTION ...]]
[--filename FILENAME] [--crawl CRAWL]
@@ -57,6 +57,8 @@ optional arguments:
-v, --verbose log verbosely; -v is INFO, -vv is DEBUG
--profile PROFILE profile to use for API authentication
-u USER, --user USER username for API authentication
+ -t TOKEN, --token TOKEN
+ token for API authentication
-c, --count print number of files for download and exit
-m, --manifest generate checksum files only and exit
-p PROCESSES, --processes PROCESSES
@@ -109,12 +111,26 @@ Order of precedence is command line, environment, config file.
The following command downloads the WARC files available from a crawl
with `crawl id` 256119 and logs program output to a file named
-`out.log`. Downloads are carried out by one process.
+`out.log`. The program will prompt the user to enter the password for
+user `myusername`. Downloads are carried out by one process.
+
+```
+ $ wasapi-client -u myusername --crawl 256119 --log /tmp/out.log -p 1
+```
+
+The following command downloads similarly, but user credentials are
+supplied by a configuration file.
```
$ wasapi-client --profile unt --crawl 256119 --log out.log -p 1
```
+You may supply an API token instead of user credentials.
+
+```
+ $ wasapi-client --token thisistheAPItokenIwasgiven --crawl 256119 --log out.log -p 1
+```
+
The following command downloads the WARC files available from crawls
that occurred in the specified time range. Verbose logging is being
written to a file named out.log. Downloads are happening via four
diff --git a/wasapi_client.py b/wasapi_client.py
index dbb7509..1c50cfd 100755
--- a/wasapi_client.py
+++ b/wasapi_client.py
@@ -73,13 +73,14 @@ class WASAPIManifestError(Exception):
pass
-def make_session(auth=None):
+def make_session(auth=None, headers={}):
"""Make a session that will store our auth.
`auth` is a tuple of the form (user, password)
"""
session = requests.Session()
session.auth = auth
+ session.headers.update(headers)
return session
@@ -100,17 +101,17 @@ def get_webdata(webdata_uri, session):
sys.exit('Non-JSON response from {}:\n{}'.format(webdata_uri, err))
-def get_files_count(webdata_uri, auth=None):
+def get_files_count(webdata_uri, auth=None, headers={}):
"""Return total number of downloadable files."""
- session = make_session(auth)
+ session = make_session(auth, headers)
webdata = get_webdata(webdata_uri, session)
session.close()
return webdata.get('count', None)
-def get_files_size(page_uri, auth=None):
+def get_files_size(page_uri, auth=None, headers={}):
"""Return total size (bytes) of downloadable files."""
- session = make_session(auth)
+ session = make_session(auth, headers)
total = 0
count = 0
webdata = None
@@ -145,7 +146,8 @@ class Downloads:
each available hash algorithm.
"""
- def __init__(self, page_uri, auth=None, download=True, destination=''):
+ def __init__(self, page_uri, auth=None, download=True, destination='',
+ headers={}):
self.page_uri = page_uri
self.auth = auth
self.download = download
@@ -154,11 +156,12 @@ class Downloads:
self.checksums = defaultdict(list)
self.urls = []
self.destination = '' if destination == '.' else destination
+ self.headers = headers
self.populate_downloads()
def populate_downloads(self):
"""Repeat webdata requests to gather downloadable file info."""
- session = make_session(self.auth)
+ session = make_session(self.auth, self.headers)
current_uri = self.page_uri
while current_uri:
webdata = get_webdata(current_uri, session)
@@ -333,11 +336,11 @@ class Downloader(multiprocessing.Process):
"""Worker for downloading web files with a persistent session."""
def __init__(self, get_q, result_q, log_q, log_level=logging.ERROR,
- auth=None, destination='.', *args, **kwargs):
+ auth=None, destination='.', headers={}, *args, **kwargs):
super(Downloader, self).__init__(*args, **kwargs)
self.get_q = get_q
self.result_q = result_q
- self.session = make_session(auth)
+ self.session = make_session(auth, headers)
self.destination = destination
configure_worker_logging(log_q, log_level)
@@ -430,6 +433,10 @@ def _parse_args(args=sys.argv[1:]):
'--user',
dest='user',
help='username for API authentication')
+ auth_group.add_argument('-t',
+ '--token',
+ dest='token',
+ help='token for API authentication')
out_group = parser.add_mutually_exclusive_group()
out_group.add_argument('-c',
@@ -569,39 +576,46 @@ def main():
query = ''
webdata_uri = '{}{}'.format(args.base_uri, query)
- # Generate authentication tuple for the API calls.
- auth = get_credentials(args.user, args.profile)
+ # Set up authentication.
+ auth = None
+ headers = {}
+ if args.token:
+ # Set the HTTP Authentication header.
+ headers['Authorization'] = 'Token {}'.format(args.token)
+ else:
+ # Generate authentication tuple for the API calls.
+ auth = get_credentials(args.user, args.profile)
# If user wants the size, don't download files.
if args.size:
- count, size = get_files_size(webdata_uri, auth)
+ count, size = get_files_size(webdata_uri, auth, headers)
print('Number of Files: ', count)
print('Size of Files: ', convert_bytes(size))
sys.exit()
# If user wants a count, don't download files.
if args.count:
- print('Number of Files: ', get_files_count(webdata_uri, auth))
+ print('Number of Files: ', get_files_count(webdata_uri, auth, headers))
sys.exit()
# Process webdata requests to generate checksum files.
if args.manifest:
downloads = Downloads(webdata_uri, auth, download=False,
- destination=args.destination)
+ destination=args.destination, headers=headers)
downloads.generate_manifests()
sys.exit()
# Print the URLs for files that can be downloaded; don't download them.
if args.urls:
downloads = Downloads(webdata_uri, auth, download=False,
- destination=args.destination)
+ destination=args.destination, headers=headers)
for url in downloads.urls:
print(url)
sys.exit()
# Process webdata requests to fill webdata file queue.
downloads = Downloads(webdata_uri, auth, download=True,
- destination=args.destination)
+ destination=args.destination, headers=headers)
# Write manifest file(s).
if not args.skip_manifest:
@@ -617,7 +631,8 @@ def main():
except NotImplementedError:
num_processes = args.processes
for _ in range(num_processes):
- dp = Downloader(get_q, result_q, log_q, log_level, auth, args.destination)
+ dp = Downloader(get_q, result_q, log_q, log_level, auth,
+ args.destination, headers=headers)
dp.start()
download_processes.append(dp)
for dp in download_processes:
| unt-libraries/py-wasapi-client | 1fe354c1ecef222e28996b0d34d6a8d930967dfc | diff --git a/tests/test_wasapi_client.py b/tests/test_wasapi_client.py
index bc1e3e9..08d6ddb 100644
--- a/tests/test_wasapi_client.py
+++ b/tests/test_wasapi_client.py
@@ -98,8 +98,10 @@ class MockResponse403:
class Test_make_session:
def test_make_session_auth(self):
auth = ('user', 'pass')
- session = wc.make_session(auth)
+ headers = {'Authorization': 'Token lalala'}
+ session = wc.make_session(auth, headers)
assert session.auth == auth
+ assert 'Authorization' in session.headers
def test_make_session_no_auth(self):
session = wc.make_session(None)
| Support API token authentication
Users may have an API token to use for authentication instead of a username and password. | 0.0 | 1fe354c1ecef222e28996b0d34d6a8d930967dfc | [
"tests/test_wasapi_client.py::Test_make_session::test_make_session_auth"
]
| [
"tests/test_wasapi_client.py::Test_make_session::test_make_session_no_auth",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_403_forbidden",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_ConnectionError",
"tests/test_wasapi_client.py::Test_get_webdata::test_get_webdata_json_error",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_multi_page",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_no_get_q",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_urls",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_manifest",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_manifest_destination",
"tests/test_wasapi_client.py::Test_Downloads::test_populate_downloads_generate_manifest",
"tests/test_wasapi_client.py::Test_Downloads::test_write_manifest_file",
"tests/test_wasapi_client.py::Test_Downloads::test_write_manifest_file_wrong_algorithm",
"tests/test_wasapi_client.py::Test_get_files_count::test_get_files_count",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size_multi_page",
"tests/test_wasapi_client.py::Test_get_files_size::test_get_files_size_no_files",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[0-0.0B]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1023-1023.0B]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1024-1.0KB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1024000-1000.0KB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1048576-1.0MB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1073741824-1.0GB]",
"tests/test_wasapi_client.py::Test_convert_bytes::test_convert_bytes[1099511628000-1.0TB]",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_200",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_not_200",
"tests/test_wasapi_client.py::Test_download_file::test_download_get_raises_some_RequestException",
"tests/test_wasapi_client.py::Test_download_file::test_download_file_OSError",
"tests/test_wasapi_client.py::Test_download_file::test_download_check_exists_true",
"tests/test_wasapi_client.py::Test_check_exists::test_check_exists_return_true",
"tests/test_wasapi_client.py::Test_check_exists::test_check_exists_no_file",
"tests/test_wasapi_client.py::Test_check_exists::test_check_exists_file_size_mismatch",
"tests/test_wasapi_client.py::Test_check_exists::test_check_exists_checksum_fail",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_unsupported_algorithm",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_checksum_mismatch",
"tests/test_wasapi_client.py::Test_verify_file::test_verify_file_one_supported_algorithm",
"tests/test_wasapi_client.py::Test_calculate_sum::test_calculate_sum",
"tests/test_wasapi_client.py::Test_convert_queue::test_convert_queue",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_all_success",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_one_failure",
"tests/test_wasapi_client.py::Test_generate_report::test_generate_report_all_failure",
"tests/test_wasapi_client.py::TestDownloader::test_run",
"tests/test_wasapi_client.py::TestDownloader::test_run_WASAPIDownloadError",
"tests/test_wasapi_client.py::TestDownloader::test_run_file_already_verified",
"tests/test_wasapi_client.py::Test_parse_args::test_default_processes",
"tests/test_wasapi_client.py::Test_parse_args::test_SetQueryParametersAction",
"tests/test_wasapi_client.py::Test_parse_args::test_SetQueryParametersAction_multiple_collections",
"tests/test_wasapi_client.py::Test_get_credentials_env::test_get_credentials_env",
"tests/test_wasapi_client.py::Test_get_credentials_env::test_get_credentials_env_missing_one_env_var",
"tests/test_wasapi_client.py::Test_get_credentials_config::test_get_credentials_config",
"tests/test_wasapi_client.py::Test_get_credentials_config::test_get_credentials_config_missing_profile",
"tests/test_wasapi_client.py::Test_get_credentials_config::test_get_credentials_config_missing_password",
"tests/test_wasapi_client.py::Test_get_credentials::test_get_credentials_from_getpass",
"tests/test_wasapi_client.py::Test_get_credentials::test_get_credentials_from_env",
"tests/test_wasapi_client.py::Test_get_credentials::test_get_credentials_from_config",
"tests/test_wasapi_client.py::Test_get_credentials::test_get_credentials_no_credentials_provided"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2019-07-19 22:01:04+00:00 | bsd-3-clause | 6,175 |
|
unt-libraries__pyuntl-43 | diff --git a/pyuntl/untl_structure.py b/pyuntl/untl_structure.py
index b47c3fc..25b2487 100644
--- a/pyuntl/untl_structure.py
+++ b/pyuntl/untl_structure.py
@@ -1,5 +1,6 @@
import socket
import json
+import sys
import urllib.request
from lxml.etree import Element, SubElement, tostring
from pyuntl import UNTL_XML_ORDER, VOCABULARIES_URL
@@ -457,6 +458,42 @@ class Metadata(UNTLElement):
# Create the form object.
return FormGenerator(**kwargs)
+ def make_hidden(self):
+ """Make an unhidden record hidden."""
+ for element in self.children:
+ if element.tag == 'meta' and element.qualifier == 'hidden':
+ # Make the element hidden.
+ if element.content == 'False':
+ element.content = 'True'
+ return None
+ # Create a hidden meta element if it doesn't exist.
+ hidden_element = PYUNTL_DISPATCH['meta'](qualifier='hidden', content='True')
+ self.children.append(hidden_element)
+
+ def make_unhidden(self):
+ """Make a hidden record unhidden."""
+ for element in self.children:
+ if element.tag == 'meta' and element.qualifier == 'hidden':
+ # Make the element unhidden.
+ if element.content == 'True':
+ element.content = 'False'
+ return None
+ # Create a hidden meta element if it doesn't exist.
+ hidden_element = PYUNTL_DISPATCH['meta'](qualifier='hidden', content='False')
+ self.children.append(hidden_element)
+
+ @property
+ def is_hidden(self):
+ """Return True if a UNTL element is hidden."""
+ for element in self.children:
+ if element.tag == 'meta' and element.qualifier == 'hidden':
+ if element.content == 'True':
+ return True
+ else:
+ return False
+ sys.stderr.write('A hidden meta element does not exist.')
+ return False
+
class Title(UNTLElement):
def __init__(self, **kwargs):
| unt-libraries/pyuntl | a02066a0d2607c16de1591c23b71f4d36abc7591 | diff --git a/tests/untl_structure_test.py b/tests/untl_structure_test.py
index 3e82016..8f08cb6 100644
--- a/tests/untl_structure_test.py
+++ b/tests/untl_structure_test.py
@@ -587,3 +587,67 @@ def test_generate_form_data(_):
assert isinstance(fg, us.FormGenerator)
# Check missing children were added.
assert len(metadata.children) == len(metadata.contained_children)
+
+
[email protected]('test_input_content, test_output',
+ [
+ ([us.Meta(content='DC', qualifier='system'),
+ us.Meta(content='True', qualifier='hidden')],
+ True),
+ ([us.Meta(content='DC', qualifier='system'),
+ us.Meta(content='False', qualifier='hidden')],
+ False),
+ ])
+def test_Metadata_is_hidden(test_input_content, test_output):
+ """Check if a UNTL element is hidden."""
+ metadata = us.Metadata()
+ metadata.children = test_input_content
+ assert metadata.is_hidden is test_output
+
+
+def test_Metadata_is_hidden_with_no_meta_hidden_element(capsys):
+ metadata = us.Metadata()
+ metadata.children = [us.Meta(content='DC', qualifier='system')]
+ assert metadata.is_hidden is False
+ captured = capsys.readouterr()
+ assert captured.err == 'A hidden meta element does not exist.'
+
+
[email protected]('test_input_elements, test_input_content',
+ [
+ ([us.Meta(content='DC', qualifier='system'),
+ us.Meta(content='True', qualifier='hidden')],
+ True),
+ ([us.Meta(content='DC', qualifier='system'),
+ us.Meta(content='False', qualifier='hidden')],
+ False),
+ ([us.Meta(content='DC', qualifier='system')],
+ False)
+ ])
+def test_Metadata_make_hidden(test_input_elements, test_input_content):
+ """Test if a UNTL unhidden element is altered to hidden."""
+ metadata = us.Metadata()
+ metadata.children = test_input_elements
+ assert metadata.is_hidden is test_input_content
+ metadata.make_hidden()
+ assert metadata.is_hidden is True
+
+
[email protected]('test_input_elements, test_input_content',
+ [
+ ([us.Meta(content='DC', qualifier='system'),
+ us.Meta(content='True', qualifier='hidden')],
+ True),
+ ([us.Meta(content='DC', qualifier='system'),
+ us.Meta(content='False', qualifier='hidden')],
+ False),
+ ([us.Meta(content='DC', qualifier='system')],
+ False)
+ ])
+def test_Metadata_make_unhidden(test_input_elements, test_input_content):
+ """Test if a UNTL hidden element is altered to unhidden."""
+ metadata = us.Metadata()
+ metadata.children = test_input_elements
+ assert metadata.is_hidden is test_input_content
+ metadata.make_unhidden()
+ assert metadata.is_hidden is False
| Add hidden/unhidden helpers to pyuntl
I was thinking that it might be useful to add a few common methods and properties to the python version of a UNTL record.
I was thinking we could add two properties.
`record.is_hidden` and `record.is_unhidden` that would return a `True` or `False` depending on the record.
We could also add two methods, `record.make_hidden()` and `record.make_unhidden()` that could be used to adjust these values.
I'm open to different language, formatting, and whatnot on the methods or property names.
| 0.0 | a02066a0d2607c16de1591c23b71f4d36abc7591 | [
"tests/untl_structure_test.py::test_Metadata_is_hidden[test_input_content0-True]",
"tests/untl_structure_test.py::test_Metadata_is_hidden[test_input_content1-False]",
"tests/untl_structure_test.py::test_Metadata_is_hidden_with_no_meta_hidden_element",
"tests/untl_structure_test.py::test_Metadata_make_hidden[test_input_elements0-True]",
"tests/untl_structure_test.py::test_Metadata_make_hidden[test_input_elements1-False]",
"tests/untl_structure_test.py::test_Metadata_make_hidden[test_input_elements2-False]",
"tests/untl_structure_test.py::test_Metadata_make_unhidden[test_input_elements0-True]",
"tests/untl_structure_test.py::test_Metadata_make_unhidden[test_input_elements1-False]",
"tests/untl_structure_test.py::test_Metadata_make_unhidden[test_input_elements2-False]"
]
| [
"tests/untl_structure_test.py::test_UNTLStructureException",
"tests/untl_structure_test.py::test_create_untl_xml_subelement_no_children",
"tests/untl_structure_test.py::test_create_untl_xml_subelement_children",
"tests/untl_structure_test.py::test_add_missing_children",
"tests/untl_structure_test.py::test_UNTLElement_init",
"tests/untl_structure_test.py::test_UNTLElement_set_qualifier",
"tests/untl_structure_test.py::test_UNTLElement_set_qualifier_exception",
"tests/untl_structure_test.py::test_UNTLElement_add_child",
"tests/untl_structure_test.py::test_UNTLElement_add_child_exception",
"tests/untl_structure_test.py::test_UNTLElement_set_content",
"tests/untl_structure_test.py::test_UNTLElement_set_content_exception",
"tests/untl_structure_test.py::test_UNTLElement_add_form_qualifier_and_content",
"tests/untl_structure_test.py::test_UNTLElement_add_form_qualifier_and_content_mocked",
"tests/untl_structure_test.py::test_UNTLElement_add_form_qualifier_only",
"tests/untl_structure_test.py::test_UNTLElement_add_form_qualifier_only_mocked",
"tests/untl_structure_test.py::test_UNTLElement_add_form_content_only_no_parent_tag",
"tests/untl_structure_test.py::test_UNTLElement_add_form_content_only_no_parent_tag_mocked",
"tests/untl_structure_test.py::test_UNTLElement_add_form_content_and_parent_tag",
"tests/untl_structure_test.py::test_UNTLElement_add_form_content_and_parent_tag_mocked",
"tests/untl_structure_test.py::test_UNTLElement_add_form_no_qualifier_no_content_no_parent_tag",
"tests/untl_structure_test.py::test_UNTLElement_add_form_no_qualifier_no_content_no_parent_tag_mocked",
"tests/untl_structure_test.py::test_UNTLElement_add_form_no_qualifier_no_content_parent_tag",
"tests/untl_structure_test.py::test_UNTLElement_add_form_no_qualifier_no_content_parent_tag_mocked",
"tests/untl_structure_test.py::test_UNTLElement_completeness",
"tests/untl_structure_test.py::test_UNTLElement_record_length",
"tests/untl_structure_test.py::test_UNTLElement_record_content_length",
"tests/untl_structure_test.py::test_FormGenerator",
"tests/untl_structure_test.py::test_FormGenerator_hidden_is_alone",
"tests/untl_structure_test.py::test_FormGenerator_adjustable_items",
"tests/untl_structure_test.py::test_FormGenerator_get_vocabularies",
"tests/untl_structure_test.py::test_FormGenerator_fails_without_vocab_service",
"tests/untl_structure_test.py::test_Metadata_create_xml_string",
"tests/untl_structure_test.py::test_Metadata_create_xml",
"tests/untl_structure_test.py::test_Metadata_create_xml_use_namespace",
"tests/untl_structure_test.py::test_Metadata_create_element_dict",
"tests/untl_structure_test.py::test_Metadata_create_xml_file",
"tests/untl_structure_test.py::test_Metadata_create_xml_file_ascii_hex",
"tests/untl_structure_test.py::test_Metadata_create_xml_file_exception_raised",
"tests/untl_structure_test.py::test_Metadata_sort_untl",
"tests/untl_structure_test.py::test_Metadata_validate",
"tests/untl_structure_test.py::test_generate_form_data"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2020-04-13 23:12:10+00:00 | bsd-3-clause | 6,176 |
|
uptick__pymyob-27 | diff --git a/myob/api.py b/myob/api.py
index fc066ea..ec02cad 100755
--- a/myob/api.py
+++ b/myob/api.py
@@ -14,7 +14,7 @@ class Myob:
)
self.credentials = credentials
self.companyfiles = CompanyFiles(credentials)
- self._manager = Manager('', credentials, endpoints=[
+ self._manager = Manager('', credentials, raw_endpoints=[
(GET, 'Info/', 'Return API build information for each individual endpoint.'),
])
@@ -28,7 +28,7 @@ class Myob:
class CompanyFiles:
def __init__(self, credentials):
self.credentials = credentials
- self._manager = Manager('', self.credentials, endpoints=[
+ self._manager = Manager('', self.credentials, raw_endpoints=[
(ALL, '', 'Return a list of company files.'),
(GET, '[id]/', 'List endpoints available for a company file.'),
])
@@ -56,7 +56,7 @@ class CompanyFile:
self.data = raw # Dump remaining raw data here.
self.credentials = credentials
for k, v in ENDPOINTS.items():
- setattr(self, v['plural'], Manager(k, credentials, endpoints=v['methods'], company_id=self.id))
+ setattr(self, v['name'], Manager(k, credentials, endpoints=v['methods'], company_id=self.id))
def __repr__(self):
- return 'CompanyFile:\n %s' % '\n '.join(sorted(v['plural'] for v in ENDPOINTS.values()))
+ return 'CompanyFile:\n %s' % '\n '.join(sorted(v['name'] for v in ENDPOINTS.values()))
diff --git a/myob/endpoints.py b/myob/endpoints.py
index 943a830..8c1cda7 100755
--- a/myob/endpoints.py
+++ b/myob/endpoints.py
@@ -1,120 +1,90 @@
+from .utils import pluralise
+
ALL = 'ALL'
GET = 'GET'
POST = 'POST'
PUT = 'PUT'
DELETE = 'DELETE'
+CRUD = 'CRUD' # shorthand for creating the ALL|GET|POST|PUT|DELETE endpoints in one swoop
METHOD_ORDER = [ALL, GET, POST, PUT, DELETE]
ENDPOINTS = {
'Banking/': {
- 'plural': 'banking',
+ 'name': 'banking',
'methods': [
- (ALL, '', 'Return all banking types for an AccountRight company file.'),
- (ALL, 'SpendMoneyTxn/', 'Return all spendmoneytxns for an AccountRight company file.'),
- (GET, 'SpendMoneyTxn/[uid]/', 'Return selected spendmoneytxn.'),
- (PUT, 'SpendMoneyTxn/[uid]/', 'Update selected spendmoneytxn.'),
- (POST, 'SpendMoneyTxn/', 'Create new spendmoneytxn.'),
- (DELETE, 'SpendMoneyTxn/[uid]/', 'Delete selected spendmoneytxn.'),
- (ALL, 'ReceiveMoneyTxn/', 'Return all receivemoneytxns for an AccountRight company file.'),
- (GET, 'ReceiveMoneyTxn/[uid]/', 'Return selected receivemoneytxn.'),
- (PUT, 'ReceiveMoneyTxn/[uid]/', 'Update selected receivemoneytxn.'),
- (POST, 'ReceiveMoneyTxn/', 'Create new receivemoneytxn.'),
- (DELETE, 'ReceiveMoneyTxn/[uid]/', 'Delete selected receivemoneytxn.'),
+ (ALL, '', 'banking type'),
+ (CRUD, 'SpendMoneyTxn/', 'spend money transaction'),
+ (CRUD, 'ReceiveMoneyTxn/', 'receive money transaction'),
],
},
'Contact/': {
- 'plural': 'contacts',
+ 'name': 'contacts',
'methods': [
- (ALL, '', 'Return all contact types for an AccountRight company file.'),
- (ALL, 'Customer/', 'Return all customer contacts for an AccountRight company file.'),
- (GET, 'Customer/[uid]/', 'Return selected customer contact.'),
- (PUT, 'Customer/[uid]/', 'Update selected customer contact.'),
- (POST, 'Customer/', 'Create new customer contact.'),
- (DELETE, 'Customer/[uid]/', 'Delete selected customer contact.'),
- (ALL, 'Supplier/', 'Return all supplier contacts for an AccountRight company file.'),
- (GET, 'Supplier/[uid]/', 'Return selected supplier contact.'),
- (PUT, 'Supplier/[uid]/', 'Update selected supplier contact.'),
- (POST, 'Supplier/', 'Create new supplier contact.'),
- (DELETE, 'Supplier/[uid]/', 'Delete selected supplier contact.'),
+ (ALL, '', 'contact type'),
+ (CRUD, 'Customer/', 'customer contact'),
+ (CRUD, 'Supplier/', 'supplier contact'),
],
},
'Sale/Invoice/': {
- 'plural': 'invoices',
+ 'name': 'invoices',
'methods': [
- (ALL, '', 'Return all sale invoice types for an AccountRight company file.'),
- (ALL, 'Item/', 'Return item type sale invoices for an AccountRight company file.'),
- (GET, 'Item/[uid]/', 'Return selected item type sale invoice.'),
- (PUT, 'Item/[uid]/', 'Update selected item type sale invoice.'),
- (POST, 'Item/', 'Create new item type sale invoice.'),
- (DELETE, 'Item/[uid]/', 'Delete selected item type sale invoice.'),
- (ALL, 'Service/', 'Return service type sale invoices for an AccountRight company file.'),
- (GET, 'Service/[uid]/', 'Return selected service type sale invoice.'),
- (PUT, 'Service/[uid]/', 'Update selected service type sale invoice.'),
- (POST, 'Service/', 'Create new service type sale invoice.'),
- (DELETE, 'Service/[uid]/', 'Delete selected service type sale invoice.'),
+ (ALL, '', 'sale invoice type'),
+ (CRUD, 'Item/', 'item type sale invoice'),
+ (CRUD, 'Service/', 'service type sale invoice'),
]
},
'GeneralLedger/': {
- 'plural': 'general_ledger',
+ 'name': 'general_ledger',
'methods': [
- (ALL, 'TaxCode/', 'Return tax codes set up with an AccountRight company file.'),
- (GET, 'TaxCode/[uid]/', 'Return selected tax code.'),
- (PUT, 'TaxCode/[uid]/', 'Update selected tax codes.'),
- (POST, 'TaxCode/', 'Create new tax code.'),
- (DELETE, 'TaxCode/[uid]/', 'Delete selected tax code.'),
- (ALL, 'Account/', 'Return accounts set up with an AccountRight company file.'),
- (GET, 'Account/[uid]/', 'Return selected account.'),
- (PUT, 'Account/[uid]/', 'Update selected accounts.'),
- (POST, 'Account/', 'Create new account.'),
- (DELETE, 'Account/[uid]/', 'Delete selected account.'),
- (ALL, 'Category/', 'Return categories for cost center tracking.'),
- (GET, 'Category/[uid]/', 'Return selected category.'),
- (PUT, 'Category/[uid]/', 'Update selected categories.'),
- (POST, 'Category/', 'Create new category.'),
- (DELETE, 'Category/[uid]/', 'Delete selected category.'),
+ (CRUD, 'TaxCode/', 'tax code'),
+ (CRUD, 'Account/', 'account'),
+ (CRUD, 'Category/', 'cost center tracking category'),
]
},
'Inventory/': {
- 'plural': 'inventory',
+ 'name': 'inventory',
'methods': [
- (ALL, 'Item/', 'Return inventory items for an AccountRight company file.'),
- (GET, 'Item/[uid]/', 'Return selected inventory item.'),
- (PUT, 'Item/[uid]/', 'Update selected inventory items.'),
- (POST, 'Item/', 'Create new inventory item.'),
- (DELETE, 'Item/[uid]/', 'Delete selected inventory item.'),
+ (CRUD, 'Item/', 'inventory item'),
]
},
'Purchase/Order/': {
- 'plural': 'purchase_orders',
+ 'name': 'purchase_orders',
'methods': [
- (ALL, '', 'Return all purchase order types for an AccountRight company file.'),
- (ALL, 'Item/', 'Return item type purchase orders for an AccountRight company file.'),
- (GET, 'Item/[uid]/', 'Return selected item type purchase order.'),
- (PUT, 'Item/[uid]/', 'Update selected item type purchase order.'),
- (POST, 'Item/', 'Create new item type purchase order.'),
- (DELETE, 'Item/[uid]/', 'Delete selected item type purchase order.'),
+ (ALL, '', 'purchase order type'),
+ (CRUD, 'Item/', 'item type purchase order'),
]
},
'Purchase/Bill/': {
- 'plural': 'purchase_bills',
+ 'name': 'purchase_bills',
'methods': [
- (ALL, '', 'Return all purchase bill types for an AccountRight company file.'),
- (ALL, 'Item/', 'Return item type purchase bills for an AccountRight company file.'),
- (GET, 'Item/[uid]/', 'Return selected item type purchase bill.'),
- (PUT, 'Item/[uid]/', 'Update selected item type purchase bill.'),
- (POST, 'Item/', 'Create new item type purchase bill.'),
- (DELETE, 'Item/[uid]/', 'Delete selected item type purchase bill.'),
- (ALL, 'Service/', 'Return service type purchase bills for an AccountRight company file.'),
- (GET, 'Service/[uid]/', 'Return selected service type purchase bill.'),
- (PUT, 'Service/[uid]/', 'Update selected service type purchase bill.'),
- (POST, 'Service/', 'Create new service type purchase bill.'),
- (DELETE, 'Service/[uid]/', 'Delete selected service type purchase bill.'),
- (ALL, 'Miscellaneous/', 'Return miscellaneous type purchase bills for an AccountRight company file.'),
- (GET, 'Miscellaneous/[uid]/', 'Return selected miscellaneous type purchase bill.'),
- (PUT, 'Miscellaneous/[uid]/', 'Update selected miscellaneous type purchase bill.'),
- (POST, 'Miscellaneous/', 'Create new miscellaneous type purchase bill.'),
- (DELETE, 'Miscellaneous/[uid]/', 'Delete selected miscellaneous type purchase bill.'),
+ (ALL, '', 'purchase bill type'),
+ (CRUD, 'Item/', 'item type purchase bill'),
+ (CRUD, 'Service/', 'service type purchase bill'),
+ (CRUD, 'Miscellaneous/', 'miscellaneous type purchase bill'),
]
},
}
+
+METHOD_MAPPING = {
+ ALL: {
+ 'endpoint': lambda base: base,
+ 'hint': lambda name: 'Return all %s for an AccountRight company file.' % pluralise(name)
+ },
+ GET: {
+ 'endpoint': lambda base: base + '[uid]/',
+ 'hint': lambda name: 'Return selected %s.' % name
+ },
+ PUT: {
+ 'endpoint': lambda base: base + '[uid]/',
+ 'hint': lambda name: 'Update selected %s.' % name
+ },
+ POST: {
+ 'endpoint': lambda base: base,
+ 'hint': lambda name: 'Create new %s.' % name
+ },
+ DELETE: {
+ 'endpoint': lambda base: base + '[uid]/',
+ 'hint': lambda name: 'Delete selected %s.' % name
+ },
+}
diff --git a/myob/managers.py b/myob/managers.py
index b8edc36..92e13b8 100755
--- a/myob/managers.py
+++ b/myob/managers.py
@@ -3,7 +3,7 @@ import requests
from datetime import date
from .constants import DEFAULT_PAGE_SIZE, MYOB_BASE_URL
-from .endpoints import METHOD_ORDER
+from .endpoints import CRUD, METHOD_MAPPING, METHOD_ORDER
from .exceptions import (
MyobBadRequest,
MyobExceptionUnknown,
@@ -14,7 +14,7 @@ from .exceptions import (
class Manager:
- def __init__(self, name, credentials, company_id=None, endpoints=[]):
+ def __init__(self, name, credentials, company_id=None, endpoints=[], raw_endpoints=[]):
self.credentials = credentials
self.name = '_'.join(p for p in name.rstrip('/').split('/') if '[' not in p)
self.base_url = MYOB_BASE_URL
@@ -26,9 +26,22 @@ class Manager:
self.company_id = company_id
# Build ORM methods from given url endpoints.
- # Sort them first, to determine duplicate disambiguation order.
- sorted_endpoints = sorted(endpoints, key=lambda x: METHOD_ORDER.index(x[0]))
- for method, endpoint, hint in sorted_endpoints:
+ for method, base, name in endpoints:
+ if method == CRUD:
+ for m in METHOD_ORDER:
+ self.build_method(
+ m,
+ METHOD_MAPPING[m]['endpoint'](base),
+ METHOD_MAPPING[m]['hint'](name),
+ )
+ else:
+ self.build_method(
+ method,
+ METHOD_MAPPING[method]['endpoint'](base),
+ METHOD_MAPPING[method]['hint'](name),
+ )
+ # Build raw methods (ones where we don't want to tinker with the endpoint or hint)
+ for method, endpoint, hint in raw_endpoints:
self.build_method(method, endpoint, hint)
def build_method(self, method, endpoint, hint):
diff --git a/myob/utils.py b/myob/utils.py
new file mode 100644
index 0000000..500580e
--- /dev/null
+++ b/myob/utils.py
@@ -0,0 +1,5 @@
+def pluralise(s):
+ if s.endswith('y'):
+ return s[:-1] + 'ies'
+ else:
+ return s + 's'
| uptick/pymyob | a396ea2ac006bd55ea812dfccf36c1ec98042770 | diff --git a/tests/endpoints.py b/tests/endpoints.py
index 660b8ff..6272b56 100644
--- a/tests/endpoints.py
+++ b/tests/endpoints.py
@@ -83,16 +83,16 @@ class EndpointTests(TestCase):
self.assertEqual(repr(self.companyfile.banking), (
"BankingManager:\n"
" all() - Return all banking types for an AccountRight company file.\n"
- " delete_receivemoneytxn(uid) - Delete selected receivemoneytxn.\n"
- " delete_spendmoneytxn(uid) - Delete selected spendmoneytxn.\n"
- " get_receivemoneytxn(uid) - Return selected receivemoneytxn.\n"
- " get_spendmoneytxn(uid) - Return selected spendmoneytxn.\n"
- " post_receivemoneytxn(data) - Create new receivemoneytxn.\n"
- " post_spendmoneytxn(data) - Create new spendmoneytxn.\n"
- " put_receivemoneytxn(uid, data) - Update selected receivemoneytxn.\n"
- " put_spendmoneytxn(uid, data) - Update selected spendmoneytxn.\n"
- " receivemoneytxn() - Return all receivemoneytxns for an AccountRight company file.\n"
- " spendmoneytxn() - Return all spendmoneytxns for an AccountRight company file."
+ " delete_receivemoneytxn(uid) - Delete selected receive money transaction.\n"
+ " delete_spendmoneytxn(uid) - Delete selected spend money transaction.\n"
+ " get_receivemoneytxn(uid) - Return selected receive money transaction.\n"
+ " get_spendmoneytxn(uid) - Return selected spend money transaction.\n"
+ " post_receivemoneytxn(data) - Create new receive money transaction.\n"
+ " post_spendmoneytxn(data) - Create new spend money transaction.\n"
+ " put_receivemoneytxn(uid, data) - Update selected receive money transaction.\n"
+ " put_spendmoneytxn(uid, data) - Update selected spend money transaction.\n"
+ " receivemoneytxn() - Return all receive money transactions for an AccountRight company file.\n"
+ " spendmoneytxn() - Return all spend money transactions for an AccountRight company file."
))
self.assertEndpointReached(self.companyfile.banking.all, {}, 'GET', f'/{CID}/Banking/')
self.assertEndpointReached(self.companyfile.banking.spendmoneytxn, {}, 'GET', f'/{CID}/Banking/SpendMoneyTxn/')
@@ -141,12 +141,12 @@ class EndpointTests(TestCase):
" delete_service(uid) - Delete selected service type sale invoice.\n"
" get_item(uid) - Return selected item type sale invoice.\n"
" get_service(uid) - Return selected service type sale invoice.\n"
- " item() - Return item type sale invoices for an AccountRight company file.\n"
+ " item() - Return all item type sale invoices for an AccountRight company file.\n"
" post_item(data) - Create new item type sale invoice.\n"
" post_service(data) - Create new service type sale invoice.\n"
" put_item(uid, data) - Update selected item type sale invoice.\n"
" put_service(uid, data) - Update selected service type sale invoice.\n"
- " service() - Return service type sale invoices for an AccountRight company file."
+ " service() - Return all service type sale invoices for an AccountRight company file."
))
self.assertEndpointReached(self.companyfile.invoices.all, {}, 'GET', f'/{CID}/Sale/Invoice/')
self.assertEndpointReached(self.companyfile.invoices.item, {}, 'GET', f'/{CID}/Sale/Invoice/Item/')
@@ -163,21 +163,21 @@ class EndpointTests(TestCase):
def test_general_ledger(self):
self.assertEqual(repr(self.companyfile.general_ledger), (
"GeneralLedgerManager:\n"
- " account() - Return accounts set up with an AccountRight company file.\n"
- " category() - Return categories for cost center tracking.\n"
+ " account() - Return all accounts for an AccountRight company file.\n"
+ " category() - Return all cost center tracking categories for an AccountRight company file.\n"
" delete_account(uid) - Delete selected account.\n"
- " delete_category(uid) - Delete selected category.\n"
+ " delete_category(uid) - Delete selected cost center tracking category.\n"
" delete_taxcode(uid) - Delete selected tax code.\n"
" get_account(uid) - Return selected account.\n"
- " get_category(uid) - Return selected category.\n"
+ " get_category(uid) - Return selected cost center tracking category.\n"
" get_taxcode(uid) - Return selected tax code.\n"
" post_account(data) - Create new account.\n"
- " post_category(data) - Create new category.\n"
+ " post_category(data) - Create new cost center tracking category.\n"
" post_taxcode(data) - Create new tax code.\n"
- " put_account(uid, data) - Update selected accounts.\n"
- " put_category(uid, data) - Update selected categories.\n"
- " put_taxcode(uid, data) - Update selected tax codes.\n"
- " taxcode() - Return tax codes set up with an AccountRight company file."
+ " put_account(uid, data) - Update selected account.\n"
+ " put_category(uid, data) - Update selected cost center tracking category.\n"
+ " put_taxcode(uid, data) - Update selected tax code.\n"
+ " taxcode() - Return all tax codes for an AccountRight company file."
))
self.assertEndpointReached(self.companyfile.general_ledger.taxcode, {}, 'GET', f'/{CID}/GeneralLedger/TaxCode/')
self.assertEndpointReached(self.companyfile.general_ledger.get_taxcode, {'uid': UID}, 'GET', f'/{CID}/GeneralLedger/TaxCode/{UID}/')
@@ -200,9 +200,9 @@ class EndpointTests(TestCase):
"InventoryManager:\n"
" delete_item(uid) - Delete selected inventory item.\n"
" get_item(uid) - Return selected inventory item.\n"
- " item() - Return inventory items for an AccountRight company file.\n"
+ " item() - Return all inventory items for an AccountRight company file.\n"
" post_item(data) - Create new inventory item.\n"
- " put_item(uid, data) - Update selected inventory items."
+ " put_item(uid, data) - Update selected inventory item."
))
self.assertEndpointReached(self.companyfile.inventory.item, {}, 'GET', f'/{CID}/Inventory/Item/')
self.assertEndpointReached(self.companyfile.inventory.get_item, {'uid': UID}, 'GET', f'/{CID}/Inventory/Item/{UID}/')
@@ -216,7 +216,7 @@ class EndpointTests(TestCase):
" all() - Return all purchase order types for an AccountRight company file.\n"
" delete_item(uid) - Delete selected item type purchase order.\n"
" get_item(uid) - Return selected item type purchase order.\n"
- " item() - Return item type purchase orders for an AccountRight company file.\n"
+ " item() - Return all item type purchase orders for an AccountRight company file.\n"
" post_item(data) - Create new item type purchase order.\n"
" put_item(uid, data) - Update selected item type purchase order."
))
@@ -237,15 +237,15 @@ class EndpointTests(TestCase):
" get_item(uid) - Return selected item type purchase bill.\n"
" get_miscellaneous(uid) - Return selected miscellaneous type purchase bill.\n"
" get_service(uid) - Return selected service type purchase bill.\n"
- " item() - Return item type purchase bills for an AccountRight company file.\n"
- " miscellaneous() - Return miscellaneous type purchase bills for an AccountRight company file.\n"
+ " item() - Return all item type purchase bills for an AccountRight company file.\n"
+ " miscellaneous() - Return all miscellaneous type purchase bills for an AccountRight company file.\n"
" post_item(data) - Create new item type purchase bill.\n"
" post_miscellaneous(data) - Create new miscellaneous type purchase bill.\n"
" post_service(data) - Create new service type purchase bill.\n"
" put_item(uid, data) - Update selected item type purchase bill.\n"
" put_miscellaneous(uid, data) - Update selected miscellaneous type purchase bill.\n"
" put_service(uid, data) - Update selected service type purchase bill.\n"
- " service() - Return service type purchase bills for an AccountRight company file."
+ " service() - Return all service type purchase bills for an AccountRight company file."
))
self.assertEndpointReached(self.companyfile.purchase_bills.all, {}, 'GET', f'/{CID}/Purchase/Bill/')
self.assertEndpointReached(self.companyfile.purchase_bills.item, {}, 'GET', f'/{CID}/Purchase/Bill/Item/')
| Simplify MYOB endpoints file.
There's an awful lot of repetition going on in this file.
Most endpoints follow this same pattern of 5 possible actions:
```
(ALL, 'Item/', 'Return inventory items for an AccountRight company file.'),
(GET, 'Item/[uid]/', 'Return selected inventory item.'),
(PUT, 'Item/[uid]/', 'Update selected inventory items.'),
(POST, 'Item/', 'Create new inventory item.'),
(DELETE, 'Item/[uid]/', 'Delete selected inventory item.'),
```
Let's compress each of these into a single entry. | 0.0 | a396ea2ac006bd55ea812dfccf36c1ec98042770 | [
"tests/endpoints.py::EndpointTests::test_banking",
"tests/endpoints.py::EndpointTests::test_general_ledger",
"tests/endpoints.py::EndpointTests::test_inventory",
"tests/endpoints.py::EndpointTests::test_invoices",
"tests/endpoints.py::EndpointTests::test_purchase_bills",
"tests/endpoints.py::EndpointTests::test_purchase_orders"
]
| [
"tests/endpoints.py::EndpointTests::test_base",
"tests/endpoints.py::EndpointTests::test_companyfile",
"tests/endpoints.py::EndpointTests::test_companyfiles",
"tests/endpoints.py::EndpointTests::test_contacts",
"tests/endpoints.py::EndpointTests::test_timeout"
]
| {
"failed_lite_validators": [
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2019-02-21 00:08:31+00:00 | bsd-3-clause | 6,177 |
|
uriyyo__instapi-84 | diff --git a/instapi/models/feed.py b/instapi/models/feed.py
index 300bb30..7d0e74e 100644
--- a/instapi/models/feed.py
+++ b/instapi/models/feed.py
@@ -1,5 +1,5 @@
from dataclasses import dataclass
-from typing import Iterable, List, Optional
+from typing import Iterable, List, Optional, cast
from ..cache import cached
from ..client import client
@@ -23,6 +23,10 @@ class Feed(ResourceContainer):
like_count: int
comment_count: int = 0
+ @property
+ def caption(self) -> str:
+ return cast(str, self._media_info()["caption"]["text"])
+
@classmethod
def iter_timeline(cls) -> Iterable["Feed"]:
"""
diff --git a/instapi/models/media.py b/instapi/models/media.py
index 2ef1352..775db03 100644
--- a/instapi/models/media.py
+++ b/instapi/models/media.py
@@ -1,6 +1,7 @@
from dataclasses import dataclass
from typing import cast
+from ..cache import cached
from ..client import client
from ..types import StrDict
from .base import Entity
@@ -8,6 +9,7 @@ from .base import Entity
@dataclass(frozen=True)
class Media(Entity):
+ @cached
def _media_info(self) -> StrDict:
items, *_ = client.media_info(self.pk)["items"]
return cast(StrDict, items)
diff --git a/instapi/models/resource.py b/instapi/models/resource.py
index dfbcf93..db43a09 100644
--- a/instapi/models/resource.py
+++ b/instapi/models/resource.py
@@ -195,7 +195,7 @@ class Image(Resource):
"""
try:
from PIL import Image as PILImage
- except ImportError:
+ except ImportError: # pragma: no cover
raise RuntimeError("Inst-API is installed without pillow\npip install inst-api[pillow]")
candidate = candidate or self.best_candidate
| uriyyo/instapi | 23f0109642b8fe9c05e75130c66284033a74a652 | diff --git a/tests/unit_tests/models/test_feed.py b/tests/unit_tests/models/test_feed.py
index 5aca118..85c82ad 100644
--- a/tests/unit_tests/models/test_feed.py
+++ b/tests/unit_tests/models/test_feed.py
@@ -1,6 +1,6 @@
from pytest import fixture
-from ..conftest import random_int
+from ..conftest import random_int, random_string
from .conftest import as_dicts
@@ -109,3 +109,11 @@ class TestFeed:
feeds = feed.timeline(limit=limit)
assert feeds == feeds[:limit]
+
+ def test_caption(self, mocker, feed):
+ caption = random_string()
+ mocker.patch(
+ "instapi.models.feed.Feed._media_info", return_value={"caption": {"text": caption}}
+ )
+
+ assert feed.caption == caption
| Need implementation of getting post messages
There is not enough method to extract the text of posts using the public API.
Currently it is needed to use low-level API method `_media_info` to get a post caption.
*Example*
```python
user = User.from_username('9gag')
f, = user.feeds(limit=1)
print(f._media_info()['caption']['text'])
``` | 0.0 | 23f0109642b8fe9c05e75130c66284033a74a652 | [
"tests/unit_tests/models/test_feed.py::TestFeed::test_caption"
]
| [
"tests/unit_tests/models/test_feed.py::TestFeed::test_usertags_one_user",
"tests/unit_tests/models/test_feed.py::TestFeed::test_usertags_many_users",
"tests/unit_tests/models/test_feed.py::TestFeed::test_usertags_no_users",
"tests/unit_tests/models/test_feed.py::TestFeed::test_like",
"tests/unit_tests/models/test_feed.py::TestFeed::test_unlike",
"tests/unit_tests/models/test_feed.py::TestFeed::test_liked_by_user_in_likers",
"tests/unit_tests/models/test_feed.py::TestFeed::test_liked_by_user_not_in_likers",
"tests/unit_tests/models/test_feed.py::TestFeed::test_iter_likes",
"tests/unit_tests/models/test_feed.py::TestFeed::test_likes_without_limit",
"tests/unit_tests/models/test_feed.py::TestFeed::test_likes_with_limit",
"tests/unit_tests/models/test_feed.py::TestFeed::test_iter_comments",
"tests/unit_tests/models/test_feed.py::TestFeed::test_comments_without_limit",
"tests/unit_tests/models/test_feed.py::TestFeed::test_comments_with_limit",
"tests/unit_tests/models/test_feed.py::TestFeed::test_iter_timeline",
"tests/unit_tests/models/test_feed.py::TestFeed::test_timeline_without_limit",
"tests/unit_tests/models/test_feed.py::TestFeed::test_timeline_with_limit"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-01-16 13:09:24+00:00 | mit | 6,178 |
|
urllib3__urllib3-1657 | diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py
index a138bb2a..86b9198a 100644
--- a/src/urllib3/connection.py
+++ b/src/urllib3/connection.py
@@ -429,7 +429,7 @@ def _match_hostname(cert, asserted_hostname):
try:
match_hostname(cert, asserted_hostname)
except CertificateError as e:
- log.error(
+ log.warning(
"Certificate did not match expected hostname: %s. " "Certificate: %s",
asserted_hostname,
cert,
| urllib3/urllib3 | 5b047b645f5f93900d5e2fc31230848c25eb1f5f | diff --git a/test/test_connection.py b/test/test_connection.py
index 5969a089..77794898 100644
--- a/test/test_connection.py
+++ b/test/test_connection.py
@@ -32,7 +32,7 @@ class TestConnection(object):
cert = {"subjectAltName": [("DNS", "foo")]}
asserted_hostname = "bar"
try:
- with mock.patch("urllib3.connection.log.error") as mock_log:
+ with mock.patch("urllib3.connection.log.warning") as mock_log:
_match_hostname(cert, asserted_hostname)
except CertificateError as e:
assert "hostname 'bar' doesn't match 'foo'" in str(e)
| urllib3 should not log an error on certificate mismatch
Logging an error and then reraising the exception does not achieve much as the application code will have to handle the exception anyway. It's better to let the application decide if it's a noteworthy event or not.
I personally don't think that a certificate mismatch is different from a server not responding or the other dozens of failures that can happen while marking an HTTP request (where urllib3 does not log an error).
In my case the "error" is reported to Sentry but there is nothing I can do as a client to fix it, which is usually a pretty good indicator that the log level should be changed to something else. If it was up to me I would change it to an `info` level.
https://github.com/urllib3/urllib3/blob/2c055b4a60affa3529660b928fff375fde3993f7/src/urllib3/connection.py#L428-L440 | 0.0 | 5b047b645f5f93900d5e2fc31230848c25eb1f5f | [
"test/test_connection.py::TestConnection::test_match_hostname_mismatch"
]
| [
"test/test_connection.py::TestConnection::test_match_hostname_match",
"test/test_connection.py::TestConnection::test_match_hostname_empty_cert",
"test/test_connection.py::TestConnection::test_match_hostname_no_cert"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2019-07-26 16:49:31+00:00 | mit | 6,179 |
|
urllib3__urllib3-1692 | diff --git a/src/urllib3/util/url.py b/src/urllib3/util/url.py
index eba42058..9675f742 100644
--- a/src/urllib3/util/url.py
+++ b/src/urllib3/util/url.py
@@ -50,7 +50,7 @@ _variations = [
"(?:(?:%(hex)s:){0,6}%(hex)s)?::",
]
-UNRESERVED_PAT = r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-"
+UNRESERVED_PAT = r"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._!\-~"
IPV6_PAT = "(?:" + "|".join([x % _subs for x in _variations]) + ")"
ZONE_ID_PAT = "(?:%25|%)(?:[" + UNRESERVED_PAT + "]|%[a-fA-F0-9]{2})+"
IPV6_ADDRZ_PAT = r"\[" + IPV6_PAT + r"(?:" + ZONE_ID_PAT + r")?\]"
@@ -63,17 +63,18 @@ IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT + "$")
BRACELESS_IPV6_ADDRZ_RE = re.compile("^" + IPV6_ADDRZ_PAT[2:-2] + "$")
ZONE_ID_RE = re.compile("(" + ZONE_ID_PAT + r")\]$")
-SUBAUTHORITY_PAT = (u"^(?:(.*)@)?" u"(%s|%s|%s)" u"(?::([0-9]{0,5}))?$") % (
+SUBAUTHORITY_PAT = (u"^(?:(.*)@)?(%s|%s|%s)(?::([0-9]{0,5}))?$") % (
REG_NAME_PAT,
IPV4_PAT,
IPV6_ADDRZ_PAT,
)
SUBAUTHORITY_RE = re.compile(SUBAUTHORITY_PAT, re.UNICODE | re.DOTALL)
-ZONE_ID_CHARS = set(
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789._!-"
+UNRESERVED_CHARS = set(
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-~"
)
-USERINFO_CHARS = ZONE_ID_CHARS | set("$&'()*+,;=:")
+SUB_DELIM_CHARS = set("!$&'()*+,;=")
+USERINFO_CHARS = UNRESERVED_CHARS | SUB_DELIM_CHARS | {":"}
PATH_CHARS = USERINFO_CHARS | {"@", "/"}
QUERY_CHARS = FRAGMENT_CHARS = PATH_CHARS | {"?"}
@@ -290,7 +291,7 @@ def _normalize_host(host, scheme):
zone_id = zone_id[3:]
else:
zone_id = zone_id[1:]
- zone_id = "%" + _encode_invalid_chars(zone_id, ZONE_ID_CHARS)
+ zone_id = "%" + _encode_invalid_chars(zone_id, UNRESERVED_CHARS)
return host[:start].lower() + zone_id + host[end:]
else:
return host.lower()
| urllib3/urllib3 | 15e05b314d890949c5629c1d2ab565ed99517089 | diff --git a/test/test_util.py b/test/test_util.py
index 73fad715..42c38824 100644
--- a/test/test_util.py
+++ b/test/test_util.py
@@ -170,6 +170,10 @@ class TestUtil(object):
"url, expected_normalized_url",
[
("HTTP://GOOGLE.COM/MAIL/", "http://google.com/MAIL/"),
+ (
+ "http://[email protected]:[email protected]/~tilde@?@",
+ "http://user%40domain.com:[email protected]/~tilde@?@",
+ ),
(
"HTTP://JeremyCline:[email protected]:8080/",
"http://JeremyCline:[email protected]:8080/",
| Tilde characters encoded in URLs starting in 1.25.4
Release 1.25.4 has a behavior change due to #1673 -- tilde characters in URLs are now percent-encoded. Some remote systems may not decode path components if they are not expecting any input other than unreserved characters. In such cases, this behavior change may cause user-visible errors.
| 0.0 | 15e05b314d890949c5629c1d2ab565ed99517089 | [
"test/test_util.py::TestUtil::test_parse_url_normalization[http://[email protected]:[email protected]/~tilde@?@-http://user%40domain.com:[email protected]/~tilde@?@]"
]
| [
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x02]",
"test/test_util.py::TestUtil::test_has_ipv6_disabled_on_appengine",
"test/test_util.py::TestUtil::test_get_host[http://www.google.com-expected_host5]",
"test/test_util.py::TestUtil::test_parse_url[http://foo:bar@localhost/-expected_url19]",
"test/test_util.py::TestUtil::test_parse_url[#-expected_url23]",
"test/test_util.py::TestUtil::test_unparse_url[-expected_url7]",
"test/test_util.py::TestUtil::test_request_uri[/foo?bar=baz-/foo?bar=baz]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x0f]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x03]",
"test/test_util.py::TestUtil::test_invalid_timeouts[kwargs2-less",
"test/test_util.py::TestUtil::test_url_vulnerabilities[//google.com/a/b/c-expected_url4]",
"test/test_util.py::TestUtil::test_parse_url[http://[email protected]:[email protected]/-expected_url28]",
"test/test_util.py::TestUtil::test_split_first[input1-expected1]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com:/-expected_url26]",
"test/test_util.py::TestUtil::test_invalid_timeouts[kwargs0-less",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com/-expected_url4]",
"test/test_util.py::TestUtil::test_is_fp_closed_object_has_none_fp",
"test/test_util.py::TestUtil::test_parse_url_normalization[http://google.com/p%5B%5d?parameter%5b%5D=%22hello%22#fragment%23-http://google.com/p%5B%5D?parameter%5B%5D=%22hello%22#fragment%23]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com/-expected_url14]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x1c]",
"test/test_util.py::TestUtil::test_get_host[http://[1080::8:800:200c:417a]/foo-expected_host28]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x14]",
"test/test_util.py::TestUtil::test_url_vulnerabilities[http://google.com/\\uff2e\\uff2e/abc-expected_url2]",
"test/test_util.py::TestUtil::test_parse_url_normalization[[::1%25]-[::1%25]]",
"test/test_util.py::TestUtil::test_get_host[http://[::192.9.5.5]/ipng-expected_host29]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x10]",
"test/test_util.py::TestUtil::test_unparse_url[/foo?bar=baz-expected_url11]",
"test/test_util.py::TestUtil::test_parse_url[http://foo:bar@localhost/-expected_url20]",
"test/test_util.py::TestUtil::test_parse_url[#?/!google.com/?foo-expected_url9]",
"test/test_util.py::TestUtil::test_unparse_url[#?/!google.com/?foo-expected_url9]",
"test/test_util.py::TestUtil::test_parse_url_normalization[HTTP://GOOGLE.COM/MAIL/-http://google.com/MAIL/]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x19]",
"test/test_util.py::TestUtil::test_get_host[http+UNIX://%2fvar%2frun%2fSOCKET/path-expected_host42]",
"test/test_util.py::TestUtil::test_resolve_ssl_version[_SSLMethod.PROTOCOL_TLSv1-_SSLMethod.PROTOCOL_TLSv1]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\r]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x04]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com:80/-expected_url15]",
"test/test_util.py::TestUtil::test_get_host[google.com/mail-expected_host2]",
"test/test_util.py::TestUtil::test_split_first[input5-expected5]",
"test/test_util.py::TestUtil::test_url_vulnerabilities[http://\\u30d2:\\u30ad@\\u30d2.abc.\\u30cb/\\u30d2?\\u30ad#\\u30ef-expected_url5]",
"test/test_util.py::TestUtil::test_get_host[173.194.35.7-expected_host36]",
"test/test_util.py::TestUtil::test_parse_and_normalize_url_paths[/..-expected_url1]",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com/mail/-expected_url1]",
"test/test_util.py::TestUtil::test_get_host[HTTP://GoOgLe.CoM:8000/mail/-expected_host34]",
"test/test_util.py::TestUtil::test_netloc[http://google.com:80/mail-google.com:80]",
"test/test_util.py::TestUtil::test_request_uri[http://google.com/-/]",
"test/test_util.py::TestUtil::test_parse_url[http://foo:bar@localhost/-expected_url21]",
"test/test_util.py::TestUtil::test_get_host[http://google.com-expected_host4]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x1a]",
"test/test_util.py::TestUtil::test_rewind_body",
"test/test_util.py::TestUtil::test_timeout",
"test/test_util.py::TestUtil::test_resolve_ssl_version[_SSLMethod.PROTOCOL_TLS-_SSLMethod.PROTOCOL_TLS]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com/mail-expected_url0]",
"test/test_util.py::TestUtil::test_parse_url[http://foo@localhost/-expected_url18]",
"test/test_util.py::TestUtil::test_parse_url_invalid_IPv6",
"test/test_util.py::TestUtil::test_make_headers[kwargs6-expected6]",
"test/test_util.py::TestUtil::test_netloc[http://google.com/mail-google.com]",
"test/test_util.py::TestUtil::test_netloc[google.com:12345-google.com:12345]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x16]",
"test/test_util.py::TestUtil::test_make_headers[kwargs10-expected10]",
"test/test_util.py::TestUtil::test_invalid_url[http://\\ud7ff.com]",
"test/test_util.py::TestUtil::test_parse_url[?-expected_url22]",
"test/test_util.py::TestUtil::test_make_headers[kwargs3-expected3]",
"test/test_util.py::TestUtil::test_parse_and_normalize_url_paths[/abc/../def-expected_url0]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x1b]",
"test/test_util.py::TestUtil::test_rewind_body_bad_position",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x12]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x15]",
"test/test_util.py::TestUtil::test_rewind_body_failed_seek",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com:80-expected_url16]",
"test/test_util.py::TestUtil::test_unparse_url[/foo?bar=baz#banana?apple/orange-expected_url12]",
"test/test_util.py::TestUtil::test_parse_url_bytes_type_error_python_3",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x0e]",
"test/test_util.py::TestUtil::test_get_host[HTTP://user:[email protected]:1234-expected_host35]",
"test/test_util.py::TestUtil::test_get_host[http://173.194.35.7:80/test-expected_host19]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x11]",
"test/test_util.py::TestUtil::test_parse_url[/abc/../def-expected_url24]",
"test/test_util.py::TestUtil::test_parse_and_normalize_url_paths[/./abc/./def/-expected_url2]",
"test/test_util.py::TestUtil::test_get_host[http://google.com/mail-expected_host0]",
"test/test_util.py::TestUtil::test_parse_url[/foo-expected_url10]",
"test/test_util.py::TestUtil::test_get_host[[2a00:1450:4001:c01::67]-expected_host20]",
"test/test_util.py::TestUtil::test_make_headers[kwargs1-expected1]",
"test/test_util.py::TestUtil::test_invalid_host[http://google.com:\\xb2\\xb2]",
"test/test_util.py::TestUtil::test_timeout_elapsed",
"test/test_util.py::TestUtil::test_parse_url[/foo?bar=baz-expected_url11]",
"test/test_util.py::TestUtil::test_url_vulnerabilities[http://google.com#@evil.com/-expected_url0]",
"test/test_util.py::TestUtil::test_unparse_url[http://foo@localhost/-expected_url18]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com/\\ud800-expected_url30]",
"test/test_util.py::TestUtil::test_get_host[http://173.194.35.7-expected_host16]",
"test/test_util.py::TestUtil::test_request_uri[http://google.com/mail-/mail]",
"test/test_util.py::TestUtil::test_url_vulnerabilities[javascript:a='@google.com:12345/';alert(0)-expected_url3]",
"test/test_util.py::TestUtil::test_has_ipv6_enabled_but_fails",
"test/test_util.py::TestUtil::test_parse_url[http://google.com:-expected_url25]",
"test/test_util.py::TestUtil::test_make_headers[kwargs8-expected8]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com-expected_url5]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x05]",
"test/test_util.py::TestUtil::test_make_headers[kwargs2-expected2]",
"test/test_util.py::TestUtil::test_request_uri[-/]",
"test/test_util.py::TestUtil::test_get_host[http://mail.google.com-expected_host6]",
"test/test_util.py::TestUtil::test_invalid_timeouts[kwargs4-cannot",
"test/test_util.py::TestUtil::test_unparse_url[google.com/mail-expected_url3]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x18]",
"test/test_util.py::TestUtil::test_invalid_timeouts[kwargs5-less",
"test/test_util.py::TestUtil::test_resolve_cert_reqs[VerifyMode.CERT_NONE-VerifyMode.CERT_NONE]",
"test/test_util.py::TestUtil::test_parse_url[google.com/mail-expected_url3]",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com/-expected_url14]",
"test/test_util.py::TestUtil::test_unparse_url[http://foo:bar@localhost/-expected_url20]",
"test/test_util.py::TestUtil::test_resolve_cert_reqs[REQUIRED-VerifyMode.CERT_REQUIRED]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\n]",
"test/test_util.py::TestUtil::test_assert_header_parsing_throws_typeerror_with_non_headers[None]",
"test/test_util.py::TestUtil::test_has_ipv6_enabled_and_working",
"test/test_util.py::TestUtil::test_get_host[GOogle.COM/mail-expected_host33]",
"test/test_util.py::TestUtil::test_request_uri[http://google.com-/]",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com:80/-expected_url15]",
"test/test_util.py::TestUtil::test_has_ipv6_disabled_on_compile",
"test/test_util.py::TestUtil::test_Url_str",
"test/test_util.py::TestUtil::test_request_uri[/-/]",
"test/test_util.py::TestUtil::test_invalid_timeouts[kwargs6-int,",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x1f]",
"test/test_util.py::TestUtil::test_parse_url[/foo?bar=baz#banana?apple/orange-expected_url12]",
"test/test_util.py::TestUtil::test_make_headers[kwargs9-expected9]",
"test/test_util.py::TestUtil::test_make_headers[kwargs7-expected7]",
"test/test_util.py::TestUtil::test_get_host[http://[2a00:1450:4001:c01::67]-expected_host21]",
"test/test_util.py::TestUtil::test_get_host[HTTP://[2a00:1450:4001:c01::67]:80/test-expected_host38]",
"test/test_util.py::TestUtil::test_resolve_cert_reqs[CERT_REQUIRED-VerifyMode.CERT_REQUIRED]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x13]",
"test/test_util.py::TestUtil::test_invalid_timeouts[kwargs1-less",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com-expected_url5]",
"test/test_util.py::TestUtil::test_get_host[http://google.com/foo=http://bar:42/baz-expected_host12]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com/-expected_url4]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x00]",
"test/test_util.py::TestUtil::test_unparse_url[/redirect?target=http://localhost:61020/-expected_url13]",
"test/test_util.py::TestUtil::test_rewind_body_failed_tell",
"test/test_util.py::TestUtil::test_parse_url_negative_port",
"test/test_util.py::TestUtil::test_parse_url_normalization[http://user:pass@[AaAa::Ff%25etH0%Ff]/%ab%Af-http://user:pass@[aaaa::ff%etH0%FF]/%AB%AF]",
"test/test_util.py::TestUtil::test_url_vulnerabilities[10.251.0.83:7777?a=1",
"test/test_util.py::TestUtil::test_get_host[HTTP://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:8000/index.html-expected_host39]",
"test/test_util.py::TestUtil::test_unparse_url[http://foo:bar@localhost/-expected_url17]",
"test/test_util.py::TestUtil::test_ip_family_ipv6_disabled",
"test/test_util.py::TestUtil::test_netloc[google.com/foobar-google.com]",
"test/test_util.py::TestUtil::test_get_host[http://[3ffe:2a00:100:7031::1]-expected_host27]",
"test/test_util.py::TestUtil::test_invalid_host[http://::1:80/]",
"test/test_util.py::TestUtil::test_get_host[http://[1080:0:0:0:8:800:200c:417a]/index.html-expected_host26]",
"test/test_util.py::TestUtil::test_unparse_url[/-expected_url8]",
"test/test_util.py::TestUtil::test_get_host[http://google.com/-expected_host3]",
"test/test_util.py::TestUtil::test_unparse_url[/foo-expected_url10]",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com/mail-expected_url2]",
"test/test_util.py::TestUtil::test_invalid_timeouts[kwargs3-cannot",
"test/test_util.py::TestUtil::test_get_host[http://[::ffff:129.144.52.38]:42/index.html-expected_host30]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[",
"test/test_util.py::TestUtil::test_get_host[abOut://eXamPlE.com?info=1-expected_host41]",
"test/test_util.py::TestUtil::test_get_host[http://google.com/mail/-expected_host1]",
"test/test_util.py::TestUtil::test_get_host[http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:8000/index.html-expected_host25]",
"test/test_util.py::TestUtil::test_url_vulnerabilities[http://127.0.0.1:6379?\\r\\nSET",
"test/test_util.py::TestUtil::test_parse_url[http://google.com?foo-expected_url6]",
"test/test_util.py::TestUtil::test_parse_url_normalization[http://google.com/p[]?parameter[]=\"hello\"#fragment#-http://google.com/p%5B%5D?parameter%5B%5D=%22hello%22#fragment%23]",
"test/test_util.py::TestUtil::test_add_stderr_logger",
"test/test_util.py::TestUtil::test_parse_url[http://google.com/mail/-expected_url1]",
"test/test_util.py::TestUtil::test_parse_url[-expected_url7]",
"test/test_util.py::TestUtil::test_assert_header_parsing_throws_typeerror_with_non_headers[object]",
"test/test_util.py::TestUtil::test_invalid_url[http://\\u2764\\ufe0f]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x7f]",
"test/test_util.py::TestUtil::test_ssl_wrap_socket_with_no_sni_warns",
"test/test_util.py::TestUtil::test_ssl_wrap_socket_creates_new_context",
"test/test_util.py::TestUtil::test_get_host[HTTP://173.194.35.7-expected_host37]",
"test/test_util.py::TestUtil::test_get_host[http://google.com:8000-expected_host8]",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com/mail-expected_url0]",
"test/test_util.py::TestUtil::test_disable_warnings",
"test/test_util.py::TestUtil::test_parse_url[http://google.com/mail-expected_url2]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x0b]",
"test/test_util.py::TestUtil::test_get_host[http://[2a00:1450:4001:c01::67]:80-expected_host23]",
"test/test_util.py::TestUtil::test_get_host[http://[2a00:1450:4001:c01::67]/test-expected_host22]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x1e]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x06]",
"test/test_util.py::TestUtil::test_get_host[http://google.com?foo=http://bar:42/baz-expected_host13]",
"test/test_util.py::TestUtil::test_get_host[http://173.194.35.7/test-expected_host17]",
"test/test_util.py::TestUtil::test_request_uri[http://google.com/mail/-/mail/]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x1d]",
"test/test_util.py::TestUtil::test_ssl_wrap_socket_loads_the_cert_chain",
"test/test_util.py::TestUtil::test_parse_url_normalization[[::Ff%etH0%Ff]/%ab%Af-[::ff%etH0%FF]/%AB%AF]",
"test/test_util.py::TestUtil::test_get_host[https://google.com-expected_host9]",
"test/test_util.py::TestUtil::test_parse_url_normalization[HTTPS://Example.Com/?Key=Value-https://example.com/?Key=Value]",
"test/test_util.py::TestUtil::test_get_host[https://google.com:8000-expected_host10]",
"test/test_util.py::TestUtil::test_const_compare_digest_fallback",
"test/test_util.py::TestUtil::test_get_host[http://[2010:836b:4179::836b:4179]-expected_host31]",
"test/test_util.py::TestUtil::test_resolve_cert_reqs[None-VerifyMode.CERT_REQUIRED]",
"test/test_util.py::TestUtil::test_parse_url[/redirect?target=http://localhost:61020/-expected_url13]",
"test/test_util.py::TestUtil::test_invalid_host[http://google.com:foo]",
"test/test_util.py::TestUtil::test_parse_url_normalization[HTTP://JeremyCline:[email protected]:8080/-http://JeremyCline:[email protected]:8080/]",
"test/test_util.py::TestUtil::test_resolve_cert_reqs[VerifyMode.CERT_REQUIRED-VerifyMode.CERT_REQUIRED]",
"test/test_util.py::TestUtil::test_unparse_url[http://foo:bar@localhost/-expected_url19]",
"test/test_util.py::TestUtil::test_split_first[input3-expected3]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\t]",
"test/test_util.py::TestUtil::test_get_host[http://[2a00:1450:4001:c01::67]:80/test-expected_host24]",
"test/test_util.py::TestUtil::test_invalid_url[http://\\udc00.com]",
"test/test_util.py::TestUtil::test_request_uri[?-/?]",
"test/test_util.py::TestUtil::test_get_host[173.194.35.7-expected_host15]",
"test/test_util.py::TestUtil::test_timeout_str",
"test/test_util.py::TestUtil::test_parse_url_normalization[Https://Example.Com/#Fragment-https://example.com/#Fragment]",
"test/test_util.py::TestUtil::test_invalid_host[http://::1/]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x01]",
"test/test_util.py::TestUtil::test_ssl_wrap_socket_loads_verify_locations",
"test/test_util.py::TestUtil::test_is_fp_closed_object_has_neither_fp_nor_closed",
"test/test_util.py::TestUtil::test_make_headers[kwargs5-expected5]",
"test/test_util.py::TestUtil::test_request_uri[#-/]",
"test/test_util.py::TestUtil::test_get_host[http://user:[email protected]:1234-expected_host11]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x08]",
"test/test_util.py::TestUtil::test_invalid_url[http://\\ud800.com]",
"test/test_util.py::TestUtil::test_unparse_url[http://foo:bar@localhost/-expected_url21]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com:80-expected_url16]",
"test/test_util.py::TestUtil::test_split_first[input0-expected0]",
"test/test_util.py::TestUtil::test_parse_and_normalize_url_paths[/.-expected_url3]",
"test/test_util.py::TestUtil::test_parse_url[http://user\":[email protected]/-expected_url29]",
"test/test_util.py::TestUtil::test_get_host[http://google.com#foo=http://bar:42/baz-expected_host14]",
"test/test_util.py::TestUtil::test_parse_url[http://foo:bar@localhost/-expected_url17]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x17]",
"test/test_util.py::TestUtil::test_split_first[input4-expected4]",
"test/test_util.py::TestUtil::test_split_first[input2-expected2]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x0c]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com#\\udc00-expected_url32]",
"test/test_util.py::TestUtil::test_ip_family_ipv6_enabled",
"test/test_util.py::TestUtil::test_parse_url[http://K\\xf6nigsg\\xe4\\xdfchen.de/stra\\xdfe-expected_url27]",
"test/test_util.py::TestUtil::test_invalid_host[http://google.com:-80]",
"test/test_util.py::TestUtil::test_parse_url[/-expected_url8]",
"test/test_util.py::TestUtil::test_resolve_ssl_version[PROTOCOL_TLSv1-_SSLMethod.PROTOCOL_TLSv1]",
"test/test_util.py::TestUtil::test_control_characters_are_percent_encoded[\\x07]",
"test/test_util.py::TestUtil::test_ssl_wrap_socket_loads_certificate_directories",
"test/test_util.py::TestUtil::test_unparse_url[http://google.com?foo-expected_url6]",
"test/test_util.py::TestUtil::test_parse_url[http://google.com?q=\\udc00-expected_url31]",
"test/test_util.py::TestUtil::test_get_host[HTTPS://[1080:0:0:0:8:800:200c:417A]/index.html-expected_host40]",
"test/test_util.py::TestUtil::test_assert_header_parsing_throws_typeerror_with_non_headers[foo]",
"test/test_util.py::TestUtil::test_is_fp_closed_object_has_fp",
"test/test_util.py::TestUtil::test_is_fp_closed_object_supports_closed",
"test/test_util.py::TestUtil::test_parse_and_normalize_url_paths[/./-expected_url4]",
"test/test_util.py::TestUtil::test_resolve_ssl_version[TLSv1-_SSLMethod.PROTOCOL_TLSv1]",
"test/test_util.py::TestUtil::test_url_vulnerabilities[http://127.0.0.1%0d%0aConnection%3a%20keep-alive-expected_url1]",
"test/test_util.py::TestUtil::test_get_host[HTTP://GOOGLE.COM/mail/-expected_host32]",
"test/test_util.py::TestUtil::test_parse_and_normalize_url_paths[/abc/./.././d/././e/.././f/./../../ghi-expected_url5]",
"test/test_util.py::TestUtil::test_get_host[http://google.com:8000/mail/-expected_host7]",
"test/test_util.py::TestUtil::test_get_host[http://173.194.35.7:80-expected_host18]"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2019-09-24 13:14:45+00:00 | mit | 6,180 |
|
urlstechie__urlchecker-python-14 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index dafc657..077dfa1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ and **Merged pull requests**. Critical items to know are:
Referenced versions in headers are tagged on Github, in parentheses are for pypi.
## [vxx](https://github.com/urlstechie/urlschecker-python/tree/master) (master)
+ - adding support for csv export (0.0.12)
- fixing bug with parameter type for retry count and timeout (0.0.11)
- first release of urlchecker module with container, tests, and brief documentation (0.0.1)
- dummy release for pypi (0.0.0)
diff --git a/README.md b/README.md
index 5dc6652..c419fbc 100644
--- a/README.md
+++ b/README.md
@@ -156,6 +156,8 @@ https://stackoverflow.com/questions/49197916/how-to-profile-cpu-usage-of-a-pytho
Done. All URLS passed.
```
+### Check GitHub Repository
+
But wouldn't it be easier to not have to clone the repository first?
Of course! We can specify a GitHub url instead, and add `--cleanup`
if we want to clean up the folder after.
@@ -171,6 +173,100 @@ sure that you provide a comma separated list *without any spaces*
urlchecker check --white-listed-files=README.md,_config.yml
```
+### Save Results
+
+If you want to save your results to file, perhaps for some kind of record or
+other data analysis, you can provide the `--save` argument:
+
+```bash
+$ urlchecker check --save results.csv .
+ original path: .
+ final path: /home/vanessa/Desktop/Code/urlstechie/urlchecker-test-repo
+ subfolder: None
+ branch: master
+ cleanup: False
+ file types: ['.md', '.py']
+ print all: True
+ url whitetlist: []
+ url patterns: []
+ file patterns: []
+ force pass: False
+ retry count: 2
+ save: results.csv
+ timeout: 5
+
+ /home/vanessa/Desktop/Code/urlstechie/urlchecker-test-repo/README.md
+ --------------------------------------------------------------------
+No urls found.
+
+ /home/vanessa/Desktop/Code/urlstechie/urlchecker-test-repo/test_files/sample_test_file.py
+ -----------------------------------------------------------------------------------------
+https://github.com/SuperKogito/URLs-checker/README.md
+https://github.com/SuperKogito/URLs-checker/README.md
+https://www.google.com/
+https://github.com/SuperKogito
+
+ /home/vanessa/Desktop/Code/urlstechie/urlchecker-test-repo/test_files/sample_test_file.md
+ -----------------------------------------------------------------------------------------
+https://github.com/SuperKogito/URLs-checker/blob/master/README.md
+https://github.com/SuperKogito/Voice-based-gender-recognition/issues
+https://github.com/SuperKogito/spafe/issues/7
+https://github.com/SuperKogito/URLs-checker
+https://github.com/SuperKogito/URLs-checker/issues
+https://github.com/SuperKogito/spafe/issues/4
+https://github.com/SuperKogito/URLs-checker/issues/2
+https://github.com/SuperKogito/URLs-checker/issues/2
+https://github.com/SuperKogito/Voice-based-gender-recognition/issues/1
+https://github.com/SuperKogito/spafe/issues/6
+https://github.com/SuperKogito/spafe/issues
+...
+
+Saving results to /home/vanessa/Desktop/Code/urlstechie/urlchecker-test-repo/results.csv
+
+
+Done. All URLS passed.
+```
+
+The file that you save to will include a comma separated value tabular listing
+of the urls, and their result. The result options are "passed" and "failed"
+and the default header is `URL,RESULT`. All of these defaults are exposed
+if you want to change them (e.g., using a tab separator or a different header)
+if you call the function from within Python. Here is an example of the default file
+produced, which should satisfy most use cases:
+
+```
+URL,RESULT
+https://github.com/SuperKogito,passed
+https://www.google.com/,passed
+https://github.com/SuperKogito/Voice-based-gender-recognition/issues,passed
+https://github.com/SuperKogito/Voice-based-gender-recognition,passed
+https://github.com/SuperKogito/spafe/issues/4,passed
+https://github.com/SuperKogito/Voice-based-gender-recognition/issues/2,passed
+https://github.com/SuperKogito/spafe/issues/5,passed
+https://github.com/SuperKogito/URLs-checker/blob/master/README.md,passed
+https://img.shields.io/,passed
+https://github.com/SuperKogito/spafe/,passed
+https://github.com/SuperKogito/spafe/issues/3,passed
+https://www.google.com/,passed
+https://github.com/SuperKogito,passed
+https://github.com/SuperKogito/spafe/issues/8,passed
+https://github.com/SuperKogito/spafe/issues/7,passed
+https://github.com/SuperKogito/Voice-based-gender-recognition/issues/1,passed
+https://github.com/SuperKogito/spafe/issues,passed
+https://github.com/SuperKogito/URLs-checker/issues,passed
+https://github.com/SuperKogito/spafe/issues/2,passed
+https://github.com/SuperKogito/URLs-checker,passed
+https://github.com/SuperKogito/spafe/issues/6,passed
+https://github.com/SuperKogito/spafe/issues/1,passed
+https://github.com/SuperKogito/URLs-checker/README.md,failed
+https://github.com/SuperKogito/URLs-checker/issues/3,failed
+https://none.html,failed
+https://github.com/SuperKogito/URLs-checker/issues/2,failed
+https://github.com/SuperKogito/URLs-checker/README.md,failed
+https://github.com/SuperKogito/URLs-checker/issues/1,failed
+https://github.com/SuperKogito/URLs-checker/issues/4,failed
+```
+
If you have any questions, please don't hesitate to [open an issue](https://github.com/urlstechie/urlchecker-python).
diff --git a/urlchecker/client/__init__.py b/urlchecker/client/__init__.py
index 581448d..3fe8333 100755
--- a/urlchecker/client/__init__.py
+++ b/urlchecker/client/__init__.py
@@ -119,6 +119,13 @@ def get_parser():
default="",
)
+# Saving
+
+ check.add_argument(
+ "--save",
+ help="Path toa csv file to save results to.",
+ default=None,
+ )
# Timeouts
diff --git a/urlchecker/client/check.py b/urlchecker/client/check.py
index 2786117..9a4ae51 100644
--- a/urlchecker/client/check.py
+++ b/urlchecker/client/check.py
@@ -9,7 +9,7 @@ import sys
import logging
from urlchecker.main.github import clone_repo, delete_repo
-from urlchecker.core.fileproc import remove_empty
+from urlchecker.core.fileproc import remove_empty, save_results
from urlchecker.core.check import run_urlchecker
from urlchecker.logger import print_success, print_failure
@@ -65,9 +65,9 @@ def main(args, extra):
print(" file patterns: %s" % white_listed_files)
print(" force pass: %s" % args.force_pass)
print(" retry count: %s" % args.retry_count)
+ print(" save: %s" % args.save)
print(" timeout: %s" % args.timeout)
-
# Run checks, get lookup of results and fails
check_results = run_urlchecker(path=path,
file_types=file_types,
@@ -78,6 +78,10 @@ def main(args, extra):
retry_count=args.retry_count,
timeout=args.timeout)
+ # save results to flie, if save indicated
+ if args.save:
+ save_results(check_results, args.save)
+
# delete repo when done, if requested
if args.cleanup:
logger.info("Cleaning up %s..." % path)
diff --git a/urlchecker/core/fileproc.py b/urlchecker/core/fileproc.py
index 412bc76..4379f3d 100644
--- a/urlchecker/core/fileproc.py
+++ b/urlchecker/core/fileproc.py
@@ -7,8 +7,10 @@ For a copy, see <https://opensource.org/licenses/MIT>.
"""
-import re
+import csv
import os
+import re
+import sys
from urlchecker.core import urlmarker
@@ -119,3 +121,46 @@ def remove_empty(file_list):
(list) list of (non None or empty string) contents.
"""
return [x for x in file_list if x not in ["", None]]
+
+
+def save_results(check_results, file_path, sep=",", header=None):
+ """
+ Given a check_results dictionary, a dict with "failed" and "passed" keys (
+ or more generally, keys to indicate some status), save a csv
+ file that has header with URL,RESULT that indicates, for each url,
+ a pass or failure. If the directory of the file path doesn't exist, exit
+ on error.
+
+ Args:
+ - check_results (dict): the check results dictionary with passed/failed
+ - file_path (str): the file path (.csv) to save to.
+ - sep (str): the separate to use (defaults to comma)
+ - header (list): if not provided, will save URL,RESULT
+
+ Returns:
+ (str) file_path: a newly saved csv with the results
+ """
+ # Ensure that the directory exists
+ file_path = os.path.abspath(file_path)
+ dirname = os.path.dirname(file_path)
+
+ if not os.path.exists(dirname):
+ sys.exit("%s does not exist, cannot save %s there." %(dirname, file_path))
+
+ # Ensure the header is provided and correct (length 2)
+ if not header:
+ header = ["URL", "RESULT"]
+
+ if len(header) != 2:
+ sys.exit("Header must be length 2 to match size of data.")
+
+ print("Saving results to %s" % file_path)
+
+ # Write to file after header row
+ with open(file_path, mode='w') as fd:
+ writer = csv.writer(fd, delimiter=sep, quotechar='"', quoting=csv.QUOTE_MINIMAL)
+ writer.writerow(header)
+ for result, items in check_results.items():
+ [writer.writerow([item, result]) for item in items];
+
+ return file_path
diff --git a/urlchecker/version.py b/urlchecker/version.py
index b8df2a4..1dcf70c 100644
--- a/urlchecker/version.py
+++ b/urlchecker/version.py
@@ -1,14 +1,13 @@
"""
-Copyright (C) 2017-2020 Vanessa Sochat.
+Copyright (c) 2020 Ayoub Malek and Vanessa Sochat
-This Source Code Form is subject to the terms of the
-Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed
-with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+This source code is licensed under the terms of the MIT license.
+For a copy, see <https://opensource.org/licenses/MIT>.
"""
-__version__ = "0.0.11"
+__version__ = "0.0.12"
AUTHOR = "Ayoub Malek, Vanessa Sochat"
AUTHOR_EMAIL = "[email protected]"
NAME = "urlchecker"
| urlstechie/urlchecker-python | 89619361e9229c81a0e50295e616451b12696371 | diff --git a/tests/test_check.py b/tests/test_check.py
index 9ac1e7f..00eca36 100644
--- a/tests/test_check.py
+++ b/tests/test_check.py
@@ -4,6 +4,7 @@ import os
import sys
import pytest
import subprocess
+import tempfile
import configparser
from urlchecker.core.fileproc import get_file_paths
from urlchecker.main.github import clone_repo, delete_repo, get_branch
@@ -109,6 +110,7 @@ def test_script(config_fname, cleanup, print_all, force_pass, rcount, timeout):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
+
@pytest.mark.parametrize('local_folder_path', ['./tests/test_files'])
@pytest.mark.parametrize('config_fname', ['./tests/_local_test_config.conf'])
@@ -182,3 +184,39 @@ def test_check_generally(retry_count):
print("\n\nDone. All URLS passed.")
if retry_count == 3:
return True
+
+
[email protected]('save', [True])
+def test_save(save):
+
+ # init config parser
+ config = configparser.ConfigParser()
+ config.read('./tests/_local_test_config.conf')
+
+ # init env variables
+ path = config['DEFAULT']["git_path_test_value"]
+ file_types = config['DEFAULT']["file_types_test_values"]
+ white_listed_urls = config['DEFAULT']["white_listed_test_urls"]
+ white_listed_patterns = config['DEFAULT']["white_listed__test_patterns"]
+
+ # Generate command
+ cmd = ["urlchecker", "check", "--subfolder", "_project", "--file-types", file_types,
+ "--white-listed-files", "conf.py", "--white-listed-urls", white_listed_urls,
+ "--white-listed_patterns", white_listed_patterns]
+
+ # Write to file
+ if save:
+ output_csv = tempfile.NamedTemporaryFile(suffix=".csv", prefix="urlchecker-")
+ cmd += ["--save", output_csv.name]
+
+ # Add final path
+ cmd.append(path)
+
+ print(" ".join(cmd))
+ # excute script
+ pipe = subprocess.run(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ if save:
+ if not os.path.exists(output_csv.name):
+ raise AssertionError
diff --git a/tests/test_fileproc.py b/tests/test_fileproc.py
index cba17f3..c4b2775 100644
--- a/tests/test_fileproc.py
+++ b/tests/test_fileproc.py
@@ -2,7 +2,8 @@
# -*- coding: utf-8 -*-
import os
import pytest
-from urlchecker.core.fileproc import check_file_type, get_file_paths, collect_links_from_file, include_file, remove_empty
+import tempfile
+from urlchecker.core.fileproc import check_file_type, get_file_paths, collect_links_from_file, include_file, remove_empty, save_results
@pytest.mark.parametrize('file_path', ["tests/test_files/sample_test_file.md",
@@ -83,3 +84,14 @@ def test_remove_empty():
urls = ["notempty", "notempty", "", None]
if len(remove_empty(urls)) != 2:
raise AssertionError
+
+
+def test_save_results():
+ """
+ test that saving results works.
+ """
+ check_results = {"failed": ["fail1", "fail2"], "passed": ["pass1", "pass2"]}
+ output_csv = tempfile.NamedTemporaryFile(suffix=".csv", prefix="urlchecker-").name
+ output_file = save_results(check_results, output_csv)
+ if not os.path.exists(output_csv):
+ raise AssertionError
| additional feature: save to file
The library should implement an option to export results to file, which will support https://github.com/urlstechie/URLs-checker/issues/23 | 0.0 | 89619361e9229c81a0e50295e616451b12696371 | [
"tests/test_check.py::test_clone_and_del_repo[https://github.com/urlstechie/urlchecker-test-repo]",
"tests/test_check.py::test_get_branch",
"tests/test_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-False-file_paths0]",
"tests/test_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-False-file_paths1]",
"tests/test_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-False-file_paths2]",
"tests/test_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-True-file_paths0]",
"tests/test_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-True-file_paths1]",
"tests/test_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-True-file_paths2]",
"tests/test_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-False-file_paths0]",
"tests/test_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-False-file_paths1]",
"tests/test_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-False-file_paths2]",
"tests/test_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-True-file_paths0]",
"tests/test_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-True-file_paths1]",
"tests/test_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-True-file_paths2]",
"tests/test_check.py::test_script[3-1-False-False-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-1-False-False-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-1-False-True-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-1-False-True-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-1-True-False-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-1-True-False-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-1-True-True-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-1-True-True-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-3-False-False-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-3-False-False-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-3-False-True-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-3-False-True-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-3-True-False-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-3-True-False-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-3-True-True-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[3-3-True-True-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-1-False-False-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-1-False-False-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-1-False-True-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-1-False-True-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-1-True-False-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-1-True-False-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-1-True-True-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-1-True-True-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-3-False-False-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-3-False-False-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-3-False-True-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-3-False-True-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-3-True-False-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-3-True-False-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-3-True-True-False-./tests/_local_test_config.conf]",
"tests/test_check.py::test_script[5-3-True-True-True-./tests/_local_test_config.conf]",
"tests/test_check.py::test_locally[./tests/_local_test_config.conf-./tests/test_files]",
"tests/test_check.py::test_check_generally[1]",
"tests/test_check.py::test_check_generally[3]",
"tests/test_check.py::test_save[True]",
"tests/test_fileproc.py::test_check_file_type[file_types0-tests/test_files/sample_test_file.md]",
"tests/test_fileproc.py::test_check_file_type[file_types0-tests/test_files/sample_test_file.py]",
"tests/test_fileproc.py::test_include_files[white_list_patterns0-tests/test_files/sample_test_file.md]",
"tests/test_fileproc.py::test_include_files[white_list_patterns0-tests/test_files/sample_test_file.py]",
"tests/test_fileproc.py::test_include_files[white_list_patterns1-tests/test_files/sample_test_file.md]",
"tests/test_fileproc.py::test_include_files[white_list_patterns1-tests/test_files/sample_test_file.py]",
"tests/test_fileproc.py::test_include_files[white_list_patterns2-tests/test_files/sample_test_file.md]",
"tests/test_fileproc.py::test_include_files[white_list_patterns2-tests/test_files/sample_test_file.py]",
"tests/test_fileproc.py::test_get_file_paths[file_types0-tests/test_files]",
"tests/test_fileproc.py::test_remove_empty",
"tests/test_fileproc.py::test_save_results"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2020-03-24 21:40:26+00:00 | mit | 6,181 |
|
urlstechie__urlchecker-python-36 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 58cb458..294cc8f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ and **Merged pull requests**. Critical items to know are:
Referenced versions in headers are tagged on Github, in parentheses are for pypi.
## [vxx](https://github.com/urlstechie/urlschecker-python/tree/master) (master)
+ - csv save uses relative paths (0.0.19)
- refactor check.py to be UrlChecker class, save with filename (0.0.18)
- default for files needs to be empty string (not None) (0.0.17)
- bug with incorrect return code on fail, add files flag (0.0.16)
diff --git a/urlchecker/core/check.py b/urlchecker/core/check.py
index f833023..17c01ce 100644
--- a/urlchecker/core/check.py
+++ b/urlchecker/core/check.py
@@ -9,6 +9,7 @@ For a copy, see <https://opensource.org/licenses/MIT>.
import csv
import os
+import re
import sys
from urlchecker.core import fileproc
from urlchecker.core.urlproc import UrlCheckResult
@@ -72,7 +73,7 @@ class UrlChecker:
def __repr__(self):
return self.__str__()
- def save_results(self, file_path, sep=",", header=None):
+ def save_results(self, file_path, sep=",", header=None, relative_paths=True):
"""
Given a check_results dictionary, a dict with "failed" and "passed" keys (
or more generally, keys to indicate some status), save a csv
@@ -84,6 +85,7 @@ class UrlChecker:
- file_path (str): the file path (.csv) to save to.
- sep (str): the separate to use (defaults to comma)
- header (list): if not provided, will save URL,RESULT
+ - relative paths (bool) : save relative paths (default True)
Returns:
(str) file_path: a newly saved csv with the results
@@ -113,6 +115,14 @@ class UrlChecker:
# Iterate through filenames, each with check results
for file_name, result in self.checks.items():
+
+ # Derive the relative path based on self.path, or relative to run
+ if relative_paths:
+ if self.path:
+ file_name = re.sub(self.path, "", file_name).strip('/')
+ else:
+ file_name = os.path.relpath(file_name)
+
[writer.writerow([url, "passed", file_name]) for url in result.passed]
[writer.writerow([url, "failed", file_name]) for url in result.failed]
diff --git a/urlchecker/version.py b/urlchecker/version.py
index 72c9090..a046825 100644
--- a/urlchecker/version.py
+++ b/urlchecker/version.py
@@ -7,7 +7,7 @@ For a copy, see <https://opensource.org/licenses/MIT>.
"""
-__version__ = "0.0.18"
+__version__ = "0.0.19"
AUTHOR = "Ayoub Malek, Vanessa Sochat"
AUTHOR_EMAIL = "[email protected], [email protected]"
NAME = "urlchecker"
| urlstechie/urlchecker-python | 2279da0c7a8027166b718a4fb59d45bd04c00c26 | diff --git a/tests/test_core_check.py b/tests/test_core_check.py
index 301020d..bd311cf 100644
--- a/tests/test_core_check.py
+++ b/tests/test_core_check.py
@@ -33,6 +33,7 @@ def test_check_files(file_paths, print_all, white_listed_urls, white_listed_patt
file_paths,
white_listed_urls=white_listed_urls,
white_listed_patterns=white_listed_patterns,
+ retry_count = 1,
)
@@ -59,6 +60,7 @@ def test_locally(local_folder_path, config_fname):
file_paths=file_paths,
white_listed_urls=white_listed_urls,
white_listed_patterns=white_listed_patterns,
+ retry_count = 1,
)
print("Done.")
@@ -111,6 +113,20 @@ def test_check_run_save(tmp_path, retry_count):
# Ensure content looks okay
for line in lines[1:]:
url, result, filename = line.split(",")
+
+ root = filename.split('/')[0]
assert url.startswith("http")
assert result in ["passed", "failed"]
assert re.search("(.py|.md)$", filename)
+
+ # Save with full path
+ saved_file = checker.save_results(output_file, relative_paths=False)
+
+ # Read in output file
+ with open(saved_file, "r") as filey:
+ lines = filey.readlines()
+
+ # Ensure content looks okay
+ for line in lines[1:]:
+ url, result, filename = line.split(",")
+ assert not filename.startswith(root)
diff --git a/tests/test_core_urlproc.py b/tests/test_core_urlproc.py
index 6f6b4d9..f573cdc 100644
--- a/tests/test_core_urlproc.py
+++ b/tests/test_core_urlproc.py
@@ -25,24 +25,25 @@ def test_check_urls(file):
assert not checker.passed
assert not checker.failed
assert not checker.all
+ assert not checker.white_listed
checker.check_urls(urls)
# Ensure we have the correct sums for passing/failing
- assert len(checker.failed + checker.passed) == checker.count
+ assert len(checker.failed + checker.passed + checker.white_listed) == checker.count
assert len(checker.all) == len(urls)
# Ensure one not whitelisted is failed
- assert "https://github.com/SuperKogito/URLs-checker/issues/1" in checker.failed
+ assert "https://github.com/SuperKogito/URLs-checker/issues/4" in checker.failed
assert checker.print_all
# Run again with whitelist of exact urls
checker = UrlCheckResult(
- white_listed_urls=["https://github.com/SuperKogito/URLs-checker/issues/1"]
+ white_listed_urls=["https://github.com/SuperKogito/URLs-checker/issues/4"]
)
checker.check_urls(urls)
assert (
- "https://github.com/SuperKogito/URLs-checker/issues/1" in checker.white_listed
+ "https://github.com/SuperKogito/URLs-checker/issues/4" in checker.white_listed
)
# Run again with whitelist of patterns
diff --git a/tests/test_core_whitelist.py b/tests/test_core_whitelist.py
index 25fe2fc..646b66a 100644
--- a/tests/test_core_whitelist.py
+++ b/tests/test_core_whitelist.py
@@ -12,7 +12,7 @@ def test_whitelisted():
assert not white_listed(url)
# Exact url provided as white list url
- assert (white_listed(url), [url])
+ assert white_listed(url, [url])
# Pattern provided as white list
- assert (white_listed(url), [], ["https://white-listed/"])
+ assert white_listed(url, [], ["https://white-listed/"])
diff --git a/tests/test_files/sample_test_file.md b/tests/test_files/sample_test_file.md
index 565c562..d068e8c 100644
--- a/tests/test_files/sample_test_file.md
+++ b/tests/test_files/sample_test_file.md
@@ -5,27 +5,15 @@ The following is a list of test urls to extract.
- [test url 3](https://github.com/SuperKogito/URLs-checker)
- [test url 4](https://github.com/SuperKogito/URLs-checker/blob/master/README.md)
- [test url 5](https://github.com/SuperKogito/URLs-checker/issues)
- - [test url 6](https://github.com/SuperKogito/URLs-checker/issues/1)
- - [test url 7](https://github.com/SuperKogito/URLs-checker/issues/2)
- - [test url 8](https://github.com/SuperKogito/URLs-checker/issues/3)
- - [test url 9](https://github.com/SuperKogito/URLs-checker/issues/4)
+ - [test url 6](https://github.com/SuperKogito/URLs-checker/issues/4)
-- [test url 10](https://github.com/SuperKogito/spafe/)
-- [test url 11](https://github.com/SuperKogito/spafe/issues)
-- [test url 12](https://github.com/SuperKogito/spafe/issues/1)
-- [test url 13](https://github.com/SuperKogito/spafe/issues/2)
-- [test url 14](https://github.com/SuperKogito/spafe/issues/3)
-- [test url 15](https://github.com/SuperKogito/spafe/issues/4)
-- [test url 16](https://github.com/SuperKogito/spafe/issues/5)
-- [test url 17](https://github.com/SuperKogito/spafe/issues/6)
-- [test url 18](https://github.com/SuperKogito/spafe/issues/7)
-- [test url 19](https://github.com/SuperKogito/spafe/issues/8)
+- [test url 7](https://github.com/SuperKogito/spafe/)
+- [test url 8](https://github.com/SuperKogito/spafe/issues)
+- [test url 9](https://github.com/SuperKogito/spafe/issues/1)
-- [test url 20](https://github.com/SuperKogito/Voice-based-gender-recognition)
-- [test url 21](https://github.com/SuperKogito/Voice-based-gender-recognition/issues)
-- [test url 22](https://github.com/SuperKogito/Voice-based-gender-recognition/issues/1)
+- [test url 10](https://github.com/SuperKogito/Voice-based-gender-recognition)
+- [test url 11](https://github.com/SuperKogito/Voice-based-gender-recognition/issues)
- [test url 23](https://github.com/SuperKogito/Voice-based-gender-recognition/issues/2)
-- [test url 24](https://github.com/SuperKogito/Voice-based-gender-recognition/issues)
- [broken_test url 1](https://none.html)
- [broken_test url 2](https://github.com/SuperKogito/URLs-checker/README.md)
| Remove "github/workspace" from filename in csv?
Not sure if this belongs to the library or action. Would it be possible (and make sense) to have the filename relative to the folder in which the URL checks are run? | 0.0 | 2279da0c7a8027166b718a4fb59d45bd04c00c26 | [
"tests/test_core_check.py::test_check_run_save[1]",
"tests/test_core_check.py::test_check_run_save[3]"
]
| [
"tests/test_core_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-False-file_paths0]",
"tests/test_core_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-False-file_paths1]",
"tests/test_core_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-False-file_paths2]",
"tests/test_core_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-True-file_paths0]",
"tests/test_core_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-True-file_paths1]",
"tests/test_core_check.py::test_check_files[white_listed_patterns0-white_listed_urls0-True-file_paths2]",
"tests/test_core_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-False-file_paths0]",
"tests/test_core_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-False-file_paths1]",
"tests/test_core_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-False-file_paths2]",
"tests/test_core_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-True-file_paths0]",
"tests/test_core_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-True-file_paths1]",
"tests/test_core_check.py::test_check_files[white_listed_patterns1-white_listed_urls0-True-file_paths2]",
"tests/test_core_check.py::test_locally[./tests/_local_test_config.conf-./tests/test_files]",
"tests/test_core_urlproc.py::test_get_user_agent",
"tests/test_core_urlproc.py::test_check_response_status_code",
"tests/test_core_whitelist.py::test_whitelisted"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2020-04-14 11:39:00+00:00 | mit | 6,182 |
|
usingnamespace__pyramid_authsanity-14 | diff --git a/setup.py b/setup.py
index e386efb..2c1f362 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ except IOError:
README = CHANGES = ''
requires = [
- 'pyramid',
+ 'pyramid>=2.0',
'zope.interface',
'pyramid_services>=0.3'
]
@@ -27,7 +27,7 @@ docs_require = requires + [
setup(
name='pyramid_authsanity',
- version='1.1.0',
+ version='2.0.0',
description='An auth policy for the Pyramid Web Framework with sane defaults.',
long_description=README + '\n\n' + CHANGES,
classifiers=[
@@ -36,11 +36,10 @@ setup(
'Intended Audience :: Developers',
'License :: OSI Approved :: ISC License (ISCL)',
'Programming Language :: Python',
- 'Programming Language :: Python :: 2.6',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
+ 'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
],
diff --git a/src/pyramid_authsanity/policy.py b/src/pyramid_authsanity/policy.py
index d30d392..96b6d0f 100644
--- a/src/pyramid_authsanity/policy.py
+++ b/src/pyramid_authsanity/policy.py
@@ -6,7 +6,7 @@ from pyramid.interfaces import (
IDebugLogger,
)
-from pyramid.security import (
+from pyramid.authorization import (
Authenticated,
Everyone,
)
diff --git a/src/pyramid_authsanity/sources.py b/src/pyramid_authsanity/sources.py
index 48d392b..ff9a047 100644
--- a/src/pyramid_authsanity/sources.py
+++ b/src/pyramid_authsanity/sources.py
@@ -1,5 +1,3 @@
-from pyramid.compat import native_
-
from webob.cookies import (
JSONSerializer,
SignedCookieProfile,
@@ -129,6 +127,13 @@ def HeaderAuthSourceInitializer(
serializer=serializer,
)
+ def _native(s, encoding='latin-1', errors='strict'):
+ """If ``s`` is an instance of ``str``, return
+ ``s``, otherwise return ``str(s, encoding, errors)``"""
+ if isinstance(s, str):
+ return s
+ return str(s, encoding, errors)
+
def _get_authorization(self):
try:
type, token = self.request.authorization
@@ -154,7 +159,7 @@ def HeaderAuthSourceInitializer(
self.cur_val = None
token = self._create_authorization(value)
- auth_info = native_(b'Bearer ' + token, 'latin-1', 'strict')
+ auth_info = self._native(b'Bearer ' + token, 'latin-1', 'strict')
return [('Authorization', auth_info)]
def headers_forget(self):
diff --git a/tox.ini b/tox.ini
index a0e4462..a197356 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,54 +1,79 @@
[tox]
envlist =
lint,
- py27,py34,py35,py36,pypy,
- docs,coverage
+ py36,py37,py38,py39,pypy3
+ py39-cover,coverage,
+ docs
[testenv]
-basepython =
- py27: python2.7
- py34: python3.4
- py35: python3.5
- py36: python3.6
- py37: python3.7
- pypy: pypy
- pypy3: pypy3
-
commands =
- pip install pyramid_authsanity[testing]
- py.test --cov --cov-report= {posargs:}
-
+ python --version
+ pytest {posargs:}
+extras =
+ testing
setenv =
COVERAGE_FILE=.coverage.{envname}
+[testenv:py39-cover]
+commands =
+ python --version
+ pytest --cov {posargs:}
+
[testenv:coverage]
skip_install = True
-basepython = python3.6
commands =
coverage combine
+ coverage xml
coverage report --fail-under=100
deps =
coverage
setenv =
COVERAGE_FILE=.coverage
+depends = py39-cover
[testenv:docs]
-basepython = python3.6
whitelist_externals =
make
commands =
pip install pyramid_authsanity[docs]
- make -C docs html BUILDDIR={envdir} SPHINXOPTS="-W -E"
+ make -C docs html BUILDDIR={envdir} "SPHINXOPTS=-W -E -D suppress_warnings=ref.term"
+extras =
+ docs
[testenv:lint]
skip_install = True
-basepython = python3.6
commands =
- flake8 src/pyramid_authsanity/
+ flake8 src/pyramid_authsanity/ tests setup.py
+ isort --check-only --df src/pyramid tests setup.py
+ black --check --diff src/pyramid tests setup.py
python setup.py check -r -s -m
check-manifest
deps =
+ black
+ check-manifest
flake8
+ isort
readme_renderer
- check-manifest
+[testenv:format]
+skip_install = true
+commands =
+ isort src/pyramid tests setup.py
+ black src/pyramid tests setup.py
+deps =
+ black
+ isort
+
+[testenv:build]
+skip_install = true
+commands =
+ # clean up build/ and dist/ folders
+ python -c 'import shutil; shutil.rmtree("dist", ignore_errors=True)'
+ python setup.py clean --all
+ # build sdist
+ python setup.py sdist --dist-dir {toxinidir}/dist
+ # build wheel from sdist
+ pip wheel -v --no-deps --no-index --no-build-isolation --wheel-dir {toxinidir}/dist --find-links {toxinidir}/dist pyramid_authsanity
+deps =
+ setuptools
+ wheel
| usingnamespace/pyramid_authsanity | 8ecbe63dba8f6db57c9e216fecde303e0d942461 | diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml
new file mode 100644
index 0000000..f2debd8
--- /dev/null
+++ b/.github/workflows/ci-tests.yml
@@ -0,0 +1,95 @@
+name: Build and test
+
+on:
+ # Only on pushes to master or one of the release branches we build on push
+ push:
+ branches:
+ - master
+ tags:
+ # Build pull requests
+ pull_request:
+
+jobs:
+ test:
+ strategy:
+ matrix:
+ py:
+ - "3.6"
+ - "3.7"
+ - "3.8"
+ - "3.9"
+ - "pypy3"
+ os:
+ - "ubuntu-latest"
+ - "windows-latest"
+ - "macos-latest"
+ architecture:
+ - x64
+ - x86
+
+ include:
+ # Only run coverage on ubuntu-latest, except on pypy3
+ - os: "ubuntu-latest"
+ pytest-args: "--cov"
+ - os: "ubuntu-latest"
+ py: "pypy3"
+ pytest-args: ""
+
+ exclude:
+ # Linux and macOS don't have x86 python
+ - os: "ubuntu-latest"
+ architecture: x86
+ - os: "macos-latest"
+ architecture: x86
+ # PyPy3 on Windows doesn't seem to work
+ - os: "windows-latest"
+ py: "pypy3"
+
+ name: "Python: ${{ matrix.py }}-${{ matrix.architecture }} on ${{ matrix.os }}"
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup python
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.py }}
+ architecture: ${{ matrix.architecture }}
+ - run: pip install tox
+ - name: Running tox
+ run: tox -e py -- ${{ matrix.pytest-args }}
+ coverage:
+ runs-on: ubuntu-latest
+ name: Validate coverage
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup python
+ uses: actions/setup-python@v1
+ with:
+ python-version: 3.9
+ architecture: x64
+ - run: pip install tox
+ - run: tox -e py39-cover,coverage
+ docs:
+ runs-on: ubuntu-latest
+ name: Build the documentation
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.9
+ architecture: x64
+ - run: pip install tox
+ - run: tox -e docs
+ lint:
+ runs-on: ubuntu-latest
+ name: Lint the package
+ steps:
+ - uses: actions/checkout@v2
+ - name: Setup python
+ uses: actions/setup-python@v2
+ with:
+ python-version: 3.9
+ architecture: x64
+ - run: pip install tox
+ - run: tox -e lint
diff --git a/tests/test_authpolicy.py b/tests/test_authpolicy.py
index 6eadb85..99f2c84 100644
--- a/tests/test_authpolicy.py
+++ b/tests/test_authpolicy.py
@@ -18,7 +18,7 @@ from pyramid_authsanity.interfaces import (
def test_clean_principal_invalid():
from pyramid_authsanity.policy import _clean_principal
- from pyramid.security import Everyone
+ from pyramid.authorization import Everyone
ret = _clean_principal(Everyone)
@@ -129,7 +129,7 @@ class TestAuthServicePolicy(object):
assert authuserid is None
def test_no_user_effective_principals(self):
- from pyramid.security import Everyone
+ from pyramid.authorization import Everyone
context = None
request = self._makeOneRequest()
source = fake_source_init([None, None])(context, request)
@@ -142,7 +142,7 @@ class TestAuthServicePolicy(object):
assert [Everyone] == groups
def test_user_bad_principal_effective_principals(self):
- from pyramid.security import Everyone
+ from pyramid.authorization import Everyone
context = None
request = self._makeOneRequest()
source = fake_source_init([Everyone, 'valid'])(context, request)
@@ -155,7 +155,7 @@ class TestAuthServicePolicy(object):
assert [Everyone] == groups
def test_effective_principals(self):
- from pyramid.security import Everyone, Authenticated
+ from pyramid.authorization import Everyone, Authenticated
context = None
request = self._makeOneRequest()
source = fake_source_init(['test', 'valid'])(context, request)
@@ -306,7 +306,7 @@ class TestAuthServicePolicyIntegration(object):
assert authuserid is None
def test_no_user_effective_principals(self):
- from pyramid.security import Everyone
+ from pyramid.authorization import Everyone
request = self._makeOneRequest()
source = fake_source_init([None, None])
auth = fake_auth_init()
@@ -318,7 +318,7 @@ class TestAuthServicePolicyIntegration(object):
assert [Everyone] == groups
def test_user_bad_principal_effective_principals(self):
- from pyramid.security import Everyone
+ from pyramid.authorization import Everyone
request = self._makeOneRequest()
source = fake_source_init([Everyone, 'valid'])
auth = fake_auth_init(fake_userid=Everyone, valid_tickets=['valid'])
@@ -330,7 +330,7 @@ class TestAuthServicePolicyIntegration(object):
assert [Everyone] == groups
def test_effective_principals(self):
- from pyramid.security import Everyone, Authenticated
+ from pyramid.authorization import Everyone, Authenticated
request = self._makeOneRequest()
source = fake_source_init(['test', 'valid'])
auth = fake_auth_init(fake_userid='test', valid_tickets=['valid'])
| Support Pyramid 2.0
`pyramid.compat` has been removed, causing this import to fail:
https://github.com/usingnamespace/pyramid_authsanity/blob/8ecbe63dba8f6db57c9e216fecde303e0d942461/src/pyramid_authsanity/sources.py#L1 | 0.0 | 8ecbe63dba8f6db57c9e216fecde303e0d942461 | [
"tests/test_authpolicy.py::test_clean_principal_invalid",
"tests/test_authpolicy.py::test_clean_principal_valid",
"tests/test_authpolicy.py::TestAuthServicePolicyInterface::test_verify",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_find_services",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_fake_source_ticket",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_valid_source_ticket",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_invalid_source_ticket",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_bad_auth_service",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_no_user_effective_principals",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_user_bad_principal_effective_principals",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_effective_principals",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_remember",
"tests/test_authpolicy.py::TestAuthServicePolicy::test_forget",
"tests/test_authpolicy.py::TestAuthServicePolicyIntegration::test_include_me",
"tests/test_authpolicy.py::TestAuthServicePolicyIntegration::test_logging"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-03-04 09:25:21+00:00 | isc | 6,183 |
|
vaidik__commentjson-46 | diff --git a/commentjson/commentjson.py b/commentjson/commentjson.py
index 4702057..998d383 100755
--- a/commentjson/commentjson.py
+++ b/commentjson/commentjson.py
@@ -26,7 +26,9 @@ except ImportError:
import lark
from lark import Lark
+from lark.lexer import Token
from lark.reconstruct import Reconstructor
+from lark.tree import Tree
parser = Lark('''
@@ -38,12 +40,13 @@ parser = Lark('''
| "true" -> true
| "false" -> false
| "null" -> null
- array : "[" [value ("," value)*] "]"
- object : "{" [pair ("," pair)*] "}"
+ array : "[" [value ("," value)*] TRAILING_COMMA? "]"
+ object : "{" [pair ("," pair)*] TRAILING_COMMA? "}"
pair : string ":" value
string : ESCAPED_STRING
COMMENT: /(#|\\/\\/)[^\\n]*/
+ TRAILING_COMMA: ","
%import common.ESCAPED_STRING
%import common.SIGNED_NUMBER
@@ -151,6 +154,15 @@ class JSONLibraryException(BaseException):
library = 'json'
+def _remove_trailing_commas(tree):
+ if isinstance(tree, Tree):
+ tree.children = [
+ _remove_trailing_commas(ch) for ch in tree.children
+ if not (isinstance(ch, Token) and ch.type == 'TRAILING_COMMA')
+ ]
+ return tree
+
+
def loads(text, *args, **kwargs):
''' Deserialize `text` (a `str` or `unicode` instance containing a JSON
document with Python or JavaScript like comments) to a Python object.
@@ -165,7 +177,7 @@ def loads(text, *args, **kwargs):
text = text.decode(detect_encoding(text), 'surrogatepass')
try:
- parsed = parser.parse(text)
+ parsed = _remove_trailing_commas(parser.parse(text))
final_text = serializer.reconstruct(parsed)
except lark.exceptions.UnexpectedCharacters:
raise ValueError('Unable to parse text', text)
| vaidik/commentjson | f720d41ee1ef398a72d3ba8cc7a2951d4fe02a17 | diff --git a/commentjson/tests/test_commentjson.py b/commentjson/tests/test_commentjson.py
index feca95b..accb45b 100755
--- a/commentjson/tests/test_commentjson.py
+++ b/commentjson/tests/test_commentjson.py
@@ -20,7 +20,8 @@ class TestCommentJson(unittest.TestCase):
'string_with_inline_comment',
'inline_has_special_characters',
'array_with_hash',
- 'inline_last_quote')
+ 'inline_last_quote',
+ 'trailing_comma')
for file_ in self.files:
fpath = os.path.join(self.path, file_)
diff --git a/commentjson/tests/trailing_comma-commented.json b/commentjson/tests/trailing_comma-commented.json
new file mode 100755
index 0000000..1e862da
--- /dev/null
+++ b/commentjson/tests/trailing_comma-commented.json
@@ -0,0 +1,15 @@
+{
+ "a": 1,
+ "c": {
+ # d is cool
+ "d": "4.3",
+ // e is cool
+ "e": {
+ "1": "1 # testing", # test comment
+ "2": "2", # some other stupid comment
+ "2.2": "2", // some other stupid comment
+ "3": "3",
+ },
+ },
+ "b": 2, # b inline comment
+}
diff --git a/commentjson/tests/trailing_comma-uncommented.json b/commentjson/tests/trailing_comma-uncommented.json
new file mode 100755
index 0000000..21b512b
--- /dev/null
+++ b/commentjson/tests/trailing_comma-uncommented.json
@@ -0,0 +1,13 @@
+{
+ "a": 1,
+ "c": {
+ "d": "4.3",
+ "e": {
+ "1": "1 # testing",
+ "2": "2",
+ "2.2": "2",
+ "3": "3"
+ }
+ },
+ "b": 2
+}
| Feature request: Ignore trailing commas
A common workflow of mine is to comment/uncomment items in a JSON file. This fails if I comment out the last item in a list/dictionary because the new last item now has a trailing comma. Is there any appetite for allowing trailing commas? Would a PR that included this functionality get accepted? | 0.0 | f720d41ee1ef398a72d3ba8cc7a2951d4fe02a17 | [
"commentjson/tests/test_commentjson.py::TestCommentJson::test_load",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_loads"
]
| [
"commentjson/tests/test_commentjson.py::TestCommentJson::test_dump",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_dump_throws_exception",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_dump_with_kwargs",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_dumping_parsing_simple_string",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_dumps",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_dumps_throws_exception",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_dumps_with_kwargs",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_load_throws_exception",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_load_with_kwargs",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_loads_throws_exception",
"commentjson/tests/test_commentjson.py::TestCommentJson::test_loads_with_kwargs"
]
| {
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2020-09-05 16:06:37+00:00 | mit | 6,184 |
|
valayDave__tell-me-your-secrets-37 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5e28236..263889c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@
- Improved processing to use multiprocessing (#35)
+### Improved
+
+- Return all signature matches within a file (#37)
+
### Fixed
- Fixed bug with gitignore flag and non-existent `.gitignore` file (#35)
diff --git a/tell_me_your_secrets/processor.py b/tell_me_your_secrets/processor.py
index 2669a25..5e2e225 100644
--- a/tell_me_your_secrets/processor.py
+++ b/tell_me_your_secrets/processor.py
@@ -1,4 +1,4 @@
-from typing import Optional, Tuple
+from typing import List
from tell_me_your_secrets.logger import get_logger
from tell_me_your_secrets.utils import get_file_data
@@ -6,44 +6,48 @@ from tell_me_your_secrets.utils import get_file_data
module_logger = get_logger()
+class SignatureMatch:
+ name: str
+ part: str
+ path: str
+
+ def __init__(self, name: str, part: str, path: str):
+ self.name = name
+ self.part = part
+ self.path = path
+
+
class Processor:
def __init__(self, signatures: list, whitelisted_strings: list, print_results: bool):
self.signatures = signatures
self.whitelisted_strings = whitelisted_strings
self.print_results = print_results
- def process_file(self, possible_compromised_path: str) -> list:
+ def process_file(self, possible_compromised_path: str) -> List[SignatureMatch]:
module_logger.debug(f'Opening File : {possible_compromised_path}')
- matched_signatures = []
file_content = get_file_data(possible_compromised_path)
if file_content is None:
- return matched_signatures
- # $ Run the Signature Checking Engine over here For different Pattern Signatures.
- signature_name, signature_part = self.run_signatures(possible_compromised_path, file_content)
- if signature_name is not None:
- matched_signatures.append(self.create_matched_signature_object(signature_name, signature_part,
- possible_compromised_path))
- if self.print_results:
- module_logger.info(f'Signature Matched : {signature_name} | On Part : {signature_part} | With '
- f'File : {possible_compromised_path}')
+ return []
+
+ matched_signatures = self.run_signatures(possible_compromised_path, file_content)
return matched_signatures
- def run_signatures(self, file_path, content) -> Tuple[Optional[str], Optional[str]]:
+ def run_signatures(self, file_path, content) -> List[SignatureMatch]:
+ matches: List[SignatureMatch] = []
for signature in self.signatures:
match_result = signature.match(file_path, content)
- if match_result.is_match:
- if match_result.matched_value in self.whitelisted_strings:
- module_logger.debug(f'Signature {signature.name} matched {match_result.matched_value} but skipping'
- f' since it is whitelisted')
- continue
- # $ Return the first signature Match.
- return signature.name, signature.part
- return None, None
-
- @staticmethod
- def create_matched_signature_object(name: str, part: str, file_path: str) -> dict:
- return {
- 'name': name,
- 'part': part,
- 'path': file_path
- }
+ if not match_result.is_match:
+ continue
+
+ if match_result.matched_value in self.whitelisted_strings:
+ module_logger.debug(f'Signature {signature.name} matched {match_result.matched_value} but skipping'
+ f' since it is whitelisted')
+ continue
+
+ if self.print_results:
+ module_logger.info(f'Signature Matched : {signature.name} | On Part : {signature.part} | With '
+ f'File : {file_path}')
+
+ matches.append(SignatureMatch(signature.name, signature.part, file_path))
+
+ return matches
| valayDave/tell-me-your-secrets | 3f5a8bcf7800f172d0bf976fd05a053259954c9d | diff --git a/test/test_processor.py b/test/test_processor.py
index 91a1a33..0c2b4d5 100644
--- a/test/test_processor.py
+++ b/test/test_processor.py
@@ -23,6 +23,7 @@ class RunSignaturesTest(unittest.TestCase):
]
processor = Processor(signatures, [], False)
- result = processor.run_signatures('file/with/issues', 'dodgy-content')
- self.assertEqual('Mock Signature', result[0])
- self.assertEqual('file', result[1])
+ results = processor.run_signatures('file/with/issues', 'dodgy-content')
+ self.assertEqual(1, len(results))
+ self.assertEqual('Mock Signature', results[0].name)
+ self.assertEqual('file', results[0].part)
| Return all issues
I noticed that this script returns first issue identified in a file rather than them all.
Would you be open to changing the behaviour to return all?
I can implement the change 👍🏼 | 0.0 | 3f5a8bcf7800f172d0bf976fd05a053259954c9d | [
"test/test_processor.py::RunSignaturesTest::test_run_signatures_matched"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2021-02-19 21:49:57+00:00 | mit | 6,185 |
|
valohai__valohai-cli-212 | diff --git a/valohai_cli/commands/execution/run/dynamic_run_command.py b/valohai_cli/commands/execution/run/dynamic_run_command.py
index 1825836..8f14603 100644
--- a/valohai_cli/commands/execution/run/dynamic_run_command.py
+++ b/valohai_cli/commands/execution/run/dynamic_run_command.py
@@ -89,7 +89,8 @@ class RunCommand(click.Command):
super().__init__(
name=sanitize_option_name(step.name.lower()),
callback=self.execute,
- epilog='Multiple files per input: --my-input=myurl --my-input=myotherurl',
+ epilog='Multiple styled parameters: --my-parameter=value1 --my-parameter=value2\n\n'
+ 'Multiple files per input: --my-input=myurl --my-input=myotherurl',
add_help_option=True,
)
self.params.append(click.Option(
@@ -121,12 +122,17 @@ class RunCommand(click.Command):
Convert a Parameter into a click Option.
"""
assert isinstance(parameter, Parameter)
+ help = parameter.description
+ is_multiple = parameter.multiple is not None
+ if is_multiple:
+ help = "(Multiple) " + (help if help else "")
option = click.Option(
param_decls=list(generate_sanitized_options(parameter.name)),
required=False, # This is done later
default=parameter.default,
- help=parameter.description,
+ help=help,
type=self.parameter_type_map.get(parameter.type, click.STRING),
+ multiple=is_multiple,
)
option.name = f'~{parameter.name}' # Tildify so we can pick these out of kwargs easily
option.help_group = 'Parameter Options' # type: ignore[attr-defined]
| valohai/valohai-cli | 47c9a32f63d1325ef9e273be9b6f8fc0e02a9bd0 | diff --git a/tests/commands/execution/test_run.py b/tests/commands/execution/test_run.py
index 53f195d..cb5eda1 100644
--- a/tests/commands/execution/test_run.py
+++ b/tests/commands/execution/test_run.py
@@ -107,6 +107,16 @@ def test_run_params(tmpdir, run_test_setup, pass_param):
values['parameters']['learning_rate'] = 1700
run_test_setup.values.update(values)
run_test_setup.run()
+ payload = run_test_setup.run_api_mock.last_create_execution_payload
+ if pass_param == 'direct':
+ assert payload['parameters']['max_steps'] == 1801
+ assert payload['parameters']['learning_rate'] == 0.1337
+ if pass_param == 'file':
+ assert payload['parameters']['max_steps'] == 300
+ assert payload['parameters']['learning_rate'] == 1700.0
+ if pass_param == 'mix':
+ assert payload['parameters']['max_steps'] == 1801
+ assert payload['parameters']['learning_rate'] == 1700.0
def test_param_type_validation_integer(runner, logged_in_and_linked, patch_git, default_run_api_mock):
@@ -183,6 +193,22 @@ def test_param_input_sanitization(runner, logged_in_and_linked, patch_git, defau
assert '--ridiculously-complex-input-name' in output
+def test_multi_parameter_serialization(run_test_setup):
+ run_test_setup.run()
+ payload = run_test_setup.run_api_mock.last_create_execution_payload
+ assert payload['parameters']['multi-parameter'] == ["one", "two", "three"]
+
+
+def test_multi_parameter_command_line_argument(run_test_setup):
+ run_test_setup.args.append('--multi-parameter=four')
+ run_test_setup.args.append('--multi-parameter=5')
+ run_test_setup.args.append('--multi-parameter="six"')
+ run_test_setup.run()
+ payload = run_test_setup.run_api_mock.last_create_execution_payload
+
+ assert payload['parameters']['multi-parameter'] == ["four", "5", "\"six\""]
+
+
def test_typo_check(runner, logged_in_and_linked, patch_git, default_run_api_mock):
with open(get_project().get_config_filename(), 'w') as yaml_fp:
yaml_fp.write(CONFIG_YAML)
diff --git a/tests/fixture_data.py b/tests/fixture_data.py
index 8c79224..eb964b8 100644
--- a/tests/fixture_data.py
+++ b/tests/fixture_data.py
@@ -462,6 +462,10 @@ CONFIG_YAML = """
default: 0.1337
- name: enable_mega_boost
type: flag
+ - name: multi-parameter
+ default: ["one","two","three"]
+ type: string
+ multiple: separate
environment-variables:
- name: testenvvar
default: 'test'
| Exec run messes multi parameters
When a step parameter is configured in valohai YAML with following properties
```yaml
name: "list-param"
default: ["one","two","three"]
multiple: separate
```
It should convert into a JSON payload with `exec run` command
```json
"parameters": {"list-param": ["one","two","three"]}
```
But currently it converts to
```json
"parameters": {"list-param": "['one','two','three']"}
```
that is then end up in command as
```shell
python ./train.py '--list-param=['"'"'one'"'"', '"'"'two'"'"', '"'"'three'"'"']'
```
Related to https://github.com/valohai/roi/issues/3118
| 0.0 | 47c9a32f63d1325ef9e273be9b6f8fc0e02a9bd0 | [
"tests/commands/execution/test_run.py::test_multi_parameter_command_line_argument[adhoc]",
"tests/commands/execution/test_run.py::test_multi_parameter_serialization[regular]",
"tests/commands/execution/test_run.py::test_multi_parameter_serialization[adhoc]",
"tests/commands/execution/test_run.py::test_multi_parameter_command_line_argument[regular]"
]
| [
"tests/commands/execution/test_run.py::test_flag_param_coercion[regular-True-True]",
"tests/commands/execution/test_run.py::test_run_env[regular]",
"tests/commands/execution/test_run.py::test_run_tags[adhoc]",
"tests/commands/execution/test_run.py::test_flag_param_coercion[adhoc-FALSE-False]",
"tests/commands/execution/test_run.py::test_flag_param_coercion[regular-no-False]",
"tests/commands/execution/test_run.py::test_run_input[regular]",
"tests/commands/execution/test_run.py::test_run_with_yaml_path[regular]",
"tests/commands/execution/test_run.py::test_flag_param_coercion[adhoc-no-False]",
"tests/commands/execution/test_run.py::test_param_type_validation_integer",
"tests/commands/execution/test_run.py::test_param_input_sanitization",
"tests/commands/execution/test_run.py::test_run_requires_step",
"tests/commands/execution/test_run.py::test_flag_param_coercion[adhoc-True-True]",
"tests/commands/execution/test_run.py::test_run_spot_restart[adhoc]",
"tests/commands/execution/test_run.py::test_flag_param_coercion[regular-FALSE-False]",
"tests/commands/execution/test_run.py::test_remote[adhoc]",
"tests/commands/execution/test_run.py::test_run_params[adhoc-mix]",
"tests/commands/execution/test_run.py::test_run_with_yaml_path[adhoc]",
"tests/commands/execution/test_run.py::test_flag_param_coercion[regular-yes-True]",
"tests/commands/execution/test_run.py::test_run_input[adhoc]",
"tests/commands/execution/test_run.py::test_run_env_var[regular-custom]",
"tests/commands/execution/test_run.py::test_remote_both_args[adhoc]",
"tests/commands/execution/test_run.py::test_run_params[regular-direct]",
"tests/commands/execution/test_run.py::test_remote_both_args[regular]",
"tests/commands/execution/test_run.py::test_run_env_var[adhoc-override-default]",
"tests/commands/execution/test_run.py::test_flag_param_coercion[regular-1-True]",
"tests/commands/execution/test_run.py::test_run_help",
"tests/commands/execution/test_run.py::test_run_params[adhoc-file]",
"tests/commands/execution/test_run.py::test_run_no_git",
"tests/commands/execution/test_run.py::test_run_params[adhoc-direct]",
"tests/commands/execution/test_run.py::test_remote[regular]",
"tests/commands/execution/test_run.py::test_run_env[adhoc]",
"tests/commands/execution/test_run.py::test_typo_check",
"tests/commands/execution/test_run.py::test_run_env_var[regular-override-default]",
"tests/commands/execution/test_run.py::test_run_spot_restart[regular]",
"tests/commands/execution/test_run.py::test_flag_param_coercion[adhoc-1-True]",
"tests/commands/execution/test_run.py::test_run_params[regular-mix]",
"tests/commands/execution/test_run.py::test_run_params[regular-file]",
"tests/commands/execution/test_run.py::test_param_type_validation_flag",
"tests/commands/execution/test_run.py::test_command_help",
"tests/commands/execution/test_run.py::test_run_tags[regular]",
"tests/commands/execution/test_run.py::test_flag_param_coercion[adhoc-yes-True]",
"tests/commands/execution/test_run.py::test_run_env_var[adhoc-custom]"
]
| {
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-09-13 06:37:57+00:00 | mit | 6,186 |
|
valohai__valohai-cli-285 | diff --git a/valohai_cli/commands/pipeline/run/run.py b/valohai_cli/commands/pipeline/run/run.py
index b30647f..ca57706 100644
--- a/valohai_cli/commands/pipeline/run/run.py
+++ b/valohai_cli/commands/pipeline/run/run.py
@@ -23,6 +23,7 @@ from valohai_cli.utils.commits import create_or_resolve_commit
@click.option('--adhoc', '-a', is_flag=True, help='Upload the current state of the working directory, then run it as an ad-hoc execution.')
@click.option('--yaml', default=None, help='The path to the configuration YAML file (valohai.yaml) file to use.')
@click.option('--tag', 'tags', multiple=True, help='Tag the pipeline. May be repeated.')
[email protected]('args', nargs=-1, type=click.UNPROCESSED, metavar='PIPELINE-OPTIONS...')
@click.pass_context
def run(
ctx: Context,
@@ -32,6 +33,7 @@ def run(
adhoc: bool,
yaml: Optional[str],
tags: List[str],
+ args: List[str],
) -> None:
"""
Start a pipeline run.
@@ -55,7 +57,42 @@ def run(
matched_pipeline = match_pipeline(config, name)
pipeline = config.pipelines[matched_pipeline]
- start_pipeline(config, pipeline, project.id, commit, tags, title)
+ start_pipeline(config, pipeline, project.id, commit, tags, args, title)
+
+
+def override_pipeline_parameters(args: List[str], pipeline_parameters: Dict[str, Any]) -> Dict[str, Any]:
+ args_dict = process_args(args)
+ if not pipeline_parameters and args_dict:
+ raise click.UsageError('Pipeline does not have any parameters')
+
+ for param in pipeline_parameters:
+ if param in args_dict:
+ pipeline_parameters[param]['expression'] = args_dict[param]
+ args_dict.pop(param)
+
+ if args_dict:
+ raise click.UsageError(f'Unknown pipeline parameter {list(args_dict.keys())}')
+
+ return pipeline_parameters
+
+
+def process_args(args: List[str]) -> Dict[str, str]:
+ i = 0
+ args_dict = {}
+ for arg in args:
+ if arg.startswith("--"):
+ arg_name = arg.lstrip("-")
+ if "=" in arg_name: # --param=value
+ name, value = arg_name.split("=", 1)
+ args_dict[name] = value
+ else: # --param value
+ next_arg_idx = i + 1
+ if next_arg_idx < len(args) and not args[next_arg_idx].startswith("--"):
+ args_dict[arg_name] = args[next_arg_idx]
+ else: # --param --param2 --param3 (flag)
+ args_dict[arg_name] = "true" # doesn't support bool as we are using strings for pipeline parameters
+ i += 1
+ return args_dict
def print_pipeline_list(ctx: Context, commit: Optional[str]) -> None:
@@ -70,18 +107,22 @@ def print_pipeline_list(ctx: Context, commit: Optional[str]) -> None:
def start_pipeline(
- config: Config,
- pipeline: Pipeline,
- project_id: str,
- commit: str,
- tags: List[str],
- title: Optional[str] = None,
+ config: Config,
+ pipeline: Pipeline,
+ project_id: str,
+ commit: str,
+ tags: List[str],
+ args: List[str],
+ title: Optional[str] = None,
) -> None:
+ converted_pipeline = PipelineConverter(config=config, commit_identifier=commit).convert_pipeline(pipeline)
+ if args:
+ converted_pipeline['parameters'] = override_pipeline_parameters(args, converted_pipeline['parameters'])
payload: Dict[str, Any] = {
"project": project_id,
"title": title or pipeline.name,
"tags": tags,
- **PipelineConverter(config=config, commit_identifier=commit).convert_pipeline(pipeline),
+ **converted_pipeline,
}
resp = request(
| valohai/valohai-cli | 3314ba7e75af47c177ee99d77eff0299ab830979 | diff --git a/tests/commands/pipeline/test_run.py b/tests/commands/pipeline/test_run.py
index b4d589b..0481d84 100644
--- a/tests/commands/pipeline/test_run.py
+++ b/tests/commands/pipeline/test_run.py
@@ -67,3 +67,27 @@ def add_valid_pipeline_yaml(yaml_path=None):
config_filename = project.get_config_filename(yaml_path=yaml_path)
with open(config_filename, 'w') as yaml_fp:
yaml_fp.write(PIPELINE_YAML)
+
+
+def test_pipeline_parameters_overriding(runner, logged_in_and_linked):
+ add_valid_pipeline_yaml()
+ # Test if it lets unknown pipeline parameters pass through
+ overriding_value = '123'
+ args = ['--adhoc', 'Train Pipeline', '--not-known', overriding_value]
+ with RunAPIMock(PROJECT_DATA['id']):
+ output = runner.invoke(run, args).output
+ assert "Unknown pipeline parameter ['not-known']" in output
+
+ args = ['--adhoc', 'Train Pipeline', '--pipeline_max_steps', overriding_value]
+ with RunAPIMock(PROJECT_DATA['id']) as mock_api:
+ output = runner.invoke(run, args).output
+
+ # Test that it runs successfully
+ assert 'Success' in output
+ assert 'Uploaded ad-hoc code' in output
+ assert 'Pipeline =21 queued' in output
+
+ # Test that the pipeline parameter was overridden
+
+ payload = mock_api.last_create_pipeline_payload['parameters']['pipeline_max_steps']
+ assert payload['expression'] == overriding_value
diff --git a/tests/commands/run_test_utils.py b/tests/commands/run_test_utils.py
index ed8659c..75900df 100644
--- a/tests/commands/run_test_utils.py
+++ b/tests/commands/run_test_utils.py
@@ -34,6 +34,7 @@ class RunAPIMock(requests_mock.Mocker):
):
super().__init__()
self.last_create_execution_payload = None
+ self.last_create_pipeline_payload = None
self.project_id = project_id
self.commit_id = commit_id
self.deployment_id = deployment_id
@@ -152,7 +153,10 @@ class RunAPIMock(requests_mock.Mocker):
assert body_json['project'] == self.project_id
assert len(body_json['edges']) == 5
assert len(body_json['nodes']) == 3
+ if "parameters" in body_json:
+ assert len(body_json['parameters']) == 1
context.status_code = 201
+ self.last_create_pipeline_payload = body_json
return PIPELINE_DATA.copy()
def handle_create_commit(self, request, context):
diff --git a/tests/fixture_data.py b/tests/fixture_data.py
index eb964b8..d28a05b 100644
--- a/tests/fixture_data.py
+++ b/tests/fixture_data.py
@@ -360,6 +360,11 @@ PIPELINE_YAML = """
- [preprocess.output.*test-images*, train.input.test-set-images]
- [preprocess.output.*test-labels*, train.input.test-set-labels]
- [train.output.model*, evaluate.input.model]
+ parameters:
+ - name: pipeline_max_steps
+ default: 1000
+ targets:
+ - Train model (MNIST).parameters.max_steps
- pipeline:
name: Train Pipeline
@@ -385,6 +390,11 @@ PIPELINE_YAML = """
- [preprocess.output.*test-images*, train.input.test-set-images]
- [preprocess.output.*test-labels*, train.input.test-set-labels]
- [train.output.model*, evaluate.input.model]
+ parameters:
+ - name: pipeline_max_steps
+ default: 1000
+ targets:
+ - Train model (MNIST).parameters.max_steps
"""
YAML_WITH_EXTRACT_TRAIN_EVAL = """
| Add override for pipeline parameters
Currently we cannot override Pipeline parameters through cli | 0.0 | 3314ba7e75af47c177ee99d77eff0299ab830979 | [
"tests/commands/pipeline/test_run.py::test_pipeline_parameters_overriding"
]
| [
"tests/commands/pipeline/test_run.py::test_pipeline_adhoc_with_yaml_path_run_success",
"tests/commands/pipeline/test_run.py::test_pipeline_run_success",
"tests/commands/pipeline/test_run.py::test_match_pipeline_ambiguous",
"tests/commands/pipeline/test_run.py::test_match_pipeline",
"tests/commands/pipeline/test_run.py::test_pipeline_run_no_name",
"tests/commands/pipeline/test_run.py::test_pipeline_adhoc_run_success"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-08-18 10:53:30+00:00 | mit | 6,187 |
|
valohai__valohai-cli-52 | diff --git a/valohai_cli/commands/execution/run.py b/valohai_cli/commands/execution/run.py
index 643cc5c..9b85f99 100644
--- a/valohai_cli/commands/execution/run.py
+++ b/valohai_cli/commands/execution/run.py
@@ -71,6 +71,7 @@ class RunCommand(click.Command):
super(RunCommand, self).__init__(
name=sanitize_name(step.name.lower()),
callback=self.execute,
+ epilog='Multiple files per input: --my-input=myurl --my-input=myotherurl',
add_help_option=True,
)
for parameter in step.parameters.values():
@@ -107,8 +108,9 @@ class RunCommand(click.Command):
option = click.Option(
param_decls=list(generate_sanitized_options(input.name)),
required=(input.default is None and not input.optional),
- default=input.default,
+ default=([input.default] if input.default else []),
metavar='URL',
+ multiple=True,
help='Input "%s"' % humanize_identifier(input.name),
)
option.name = '^%s' % input.name # Caretize so we can pick these out of kwargs easily
| valohai/valohai-cli | d78841c98ea4016a2c79bf899b44e86920535a21 | diff --git a/tests/commands/execution/test_run.py b/tests/commands/execution/test_run.py
index fc78001..7e42a90 100644
--- a/tests/commands/execution/test_run.py
+++ b/tests/commands/execution/test_run.py
@@ -83,7 +83,8 @@ def test_run(runner, logged_in_and_linked, monkeypatch, pass_param, pass_input,
if pass_input:
args.append('--in1=http://url')
- values['inputs'] = {'in1': 'http://url'}
+ args.append('--in1=http://anotherurl')
+ values['inputs'] = {'in1': ['http://url', 'http://anotherurl']}
if pass_env:
args.append('--environment=015dbd56-2670-b03e-f37c-dc342714f1b5')
| Support multiple files per input
Support for this seems to be lacking in the CLI, even if the web UI and API support it. | 0.0 | d78841c98ea4016a2c79bf899b44e86920535a21 | [
"tests/commands/execution/test_run.py::test_run[adhoc-False-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-False-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-True-True-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-True-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-False-True-False]",
"tests/commands/execution/test_run.py::test_run[regular-True-True-False]",
"tests/commands/execution/test_run.py::test_run[regular-False-True-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-True-True-False]"
]
| [
"tests/commands/execution/test_run.py::test_run[regular-False-False-False]",
"tests/commands/execution/test_run.py::test_run[regular-True-False-False]",
"tests/commands/execution/test_run.py::test_run[regular-False-False-True]",
"tests/commands/execution/test_run.py::test_param_input_sanitization",
"tests/commands/execution/test_run.py::test_run[adhoc-False-False-True]",
"tests/commands/execution/test_run.py::test_run_requires_step",
"tests/commands/execution/test_run.py::test_run[regular-True-False-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-True-False-False]",
"tests/commands/execution/test_run.py::test_typo_check",
"tests/commands/execution/test_run.py::test_run[adhoc-False-False-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-True-False-True]",
"tests/commands/execution/test_run.py::test_run_no_git"
]
| {
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false
} | 2019-02-26 15:16:47+00:00 | mit | 6,188 |
|
valohai__valohai-cli-85 | diff --git a/valohai_cli/commands/execution/run/dynamic_run_command.py b/valohai_cli/commands/execution/run/dynamic_run_command.py
index 38cf466..02eae5f 100644
--- a/valohai_cli/commands/execution/run/dynamic_run_command.py
+++ b/valohai_cli/commands/execution/run/dynamic_run_command.py
@@ -80,6 +80,9 @@ class RunCommand(click.Command):
self.params.append(self.convert_param_to_option(parameter))
for input in step.inputs.values():
self.params.append(self.convert_input_to_option(input))
+ for name, value in step.environment_variables.items():
+ if name not in self.environment_variables:
+ self.environment_variables[name] = value.default
def convert_param_to_option(self, parameter):
"""
diff --git a/valohai_cli/utils/__init__.py b/valohai_cli/utils/__init__.py
index 68053a8..4ba3f90 100644
--- a/valohai_cli/utils/__init__.py
+++ b/valohai_cli/utils/__init__.py
@@ -184,10 +184,6 @@ def parse_environment_variable_strings(envvar_strings):
environment_variables = {}
for string in envvar_strings:
key, _, value = string.partition('=')
- if not value:
- raise ValueError('Environment variable specification {string} must be in the format KEY=VALUE'.format(
- string=string,
- ))
key = key.strip()
if not key:
continue
| valohai/valohai-cli | e75957cdb64b2ef5af39cea755712334cc72c42e | diff --git a/tests/commands/execution/test_run.py b/tests/commands/execution/test_run.py
index 89b66c1..fd9e5ea 100644
--- a/tests/commands/execution/test_run.py
+++ b/tests/commands/execution/test_run.py
@@ -98,7 +98,7 @@ def test_run_requires_step(runner, logged_in_and_linked):
@pytest.mark.parametrize('pass_param', (False, True))
@pytest.mark.parametrize('pass_input', (False, True))
@pytest.mark.parametrize('pass_env', (False, True))
[email protected]('pass_env_var', (False, True))
[email protected]('pass_env_var', (None, 'custom', 'override-default'))
@pytest.mark.parametrize('adhoc', (False, True), ids=('regular', 'adhoc'))
def test_run(runner, logged_in_and_linked, monkeypatch, pass_param, pass_input, pass_env, pass_env_var, adhoc):
project_id = PROJECT_DATA['id']
@@ -130,10 +130,16 @@ def test_run(runner, logged_in_and_linked, monkeypatch, pass_param, pass_input,
args.extend(['-v', 'greeting=hello'])
args.extend(['--var', 'enable=1'])
args.extend(['-vdebug=yes'])
+ if pass_env_var == 'override-default':
+ args.extend(['--var', 'testenvvar='])
+ expected_testenvvar = ''
+ else:
+ expected_testenvvar = 'test' # default from YAML
values['environment_variables'] = {
'greeting': 'hello',
'enable': '1',
'debug': 'yes',
+ 'testenvvar': expected_testenvvar,
}
with RunAPIMock(project_id, commit_id, values):
output = runner.invoke(run, args, catch_exceptions=False).output
diff --git a/tests/fixture_data.py b/tests/fixture_data.py
index b8f4fa6..d013318 100644
--- a/tests/fixture_data.py
+++ b/tests/fixture_data.py
@@ -121,6 +121,9 @@ CONFIG_YAML = """
description: Number of steps to run the trainer
type: integer
default: 300
+ environment-variables:
+ - name: testenvvar
+ default: 'test'
"""
| CLI does not honor default environment variables in step
They're probably currently only populated into the GUI. | 0.0 | e75957cdb64b2ef5af39cea755712334cc72c42e | [
"tests/commands/execution/test_run.py::test_run[regular-override-default-False-False-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-custom-False-False-True]",
"tests/commands/execution/test_run.py::test_run[regular-custom-True-True-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-custom-True-True-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-override-default-False-False-False]",
"tests/commands/execution/test_run.py::test_run[regular-override-default-True-False-False]",
"tests/commands/execution/test_run.py::test_run[regular-custom-False-True-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-custom-False-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-override-default-True-True-False]",
"tests/commands/execution/test_run.py::test_run[regular-override-default-False-False-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-override-default-True-False-True]",
"tests/commands/execution/test_run.py::test_run[regular-override-default-True-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-custom-False-False-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-custom-False-False-False]",
"tests/commands/execution/test_run.py::test_run[regular-custom-False-True-False]",
"tests/commands/execution/test_run.py::test_run[regular-custom-False-False-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-override-default-True-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-override-default-False-True-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-override-default-False-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-override-default-False-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-custom-True-False-True]",
"tests/commands/execution/test_run.py::test_run[regular-override-default-True-False-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-custom-False-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-override-default-True-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-custom-True-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-override-default-True-False-False]",
"tests/commands/execution/test_run.py::test_run[regular-override-default-False-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-custom-True-False-False]",
"tests/commands/execution/test_run.py::test_run[regular-custom-True-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-custom-True-False-True]",
"tests/commands/execution/test_run.py::test_run[regular-custom-True-False-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-override-default-False-False-True]"
]
| [
"tests/commands/execution/test_run.py::test_run[adhoc-None-True-False-False]",
"tests/commands/execution/test_run.py::test_run[regular-None-True-False-True]",
"tests/commands/execution/test_run.py::test_run[regular-None-True-True-False]",
"tests/commands/execution/test_run.py::test_run[regular-None-False-True-True]",
"tests/commands/execution/test_run.py::test_run_help",
"tests/commands/execution/test_run.py::test_run[adhoc-None-False-False-True]",
"tests/commands/execution/test_run.py::test_run_requires_step",
"tests/commands/execution/test_run.py::test_run[regular-None-False-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-None-False-True-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-None-True-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-None-True-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-None-False-False-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-None-True-True-False]",
"tests/commands/execution/test_run.py::test_param_input_sanitization",
"tests/commands/execution/test_run.py::test_run_no_git",
"tests/commands/execution/test_run.py::test_run[regular-None-True-False-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-None-True-False-True]",
"tests/commands/execution/test_run.py::test_run[adhoc-None-False-True-True]",
"tests/commands/execution/test_run.py::test_run[regular-None-False-False-False]",
"tests/commands/execution/test_run.py::test_run[adhoc-None-False-False-False]",
"tests/commands/execution/test_run.py::test_typo_check"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2019-06-11 07:53:41+00:00 | mit | 6,189 |
|
valohai__valohai-yaml-131 | diff --git a/examples/task-example.yaml b/examples/task-example.yaml
index efbe2ee..1405282 100644
--- a/examples/task-example.yaml
+++ b/examples/task-example.yaml
@@ -46,7 +46,11 @@
- task:
step: run training
name: task 4 logspace
- type: random_search
+ type: RANDOM-SEARCH # will be normalized
+ execution-batch-size: 42
+ execution-count: 420
+ optimization-target-metric: goodness
+ optimization-target-value: 7.2
parameters:
- name: A
style: logspace
diff --git a/valohai_yaml/objs/task.py b/valohai_yaml/objs/task.py
index c6774ad..eb00644 100644
--- a/valohai_yaml/objs/task.py
+++ b/valohai_yaml/objs/task.py
@@ -29,7 +29,7 @@ class TaskType(Enum):
return TaskType.GRID_SEARCH
if isinstance(value, TaskType):
return value
- value = str(value).lower()
+ value = str(value).lower().replace("-", "_")
return TaskType(value)
@@ -75,8 +75,7 @@ class Task(Item):
def parse(cls, data: Any) -> Task:
kwargs = data.copy()
kwargs["parameters"] = consume_array_of(kwargs, "parameters", VariantParameter)
- kwargs["stop_condition"] = kwargs.pop("stop-condition", None)
- inst = cls(**kwargs)
+ inst = cls(**{key.replace("-", "_"): value for key, value in kwargs.items()})
inst._original_data = data
return inst
diff --git a/valohai_yaml/schema/task.yaml b/valohai_yaml/schema/task.yaml
index cbe188b..7b84fb9 100644
--- a/valohai_yaml/schema/task.yaml
+++ b/valohai_yaml/schema/task.yaml
@@ -8,24 +8,18 @@ properties:
step:
type: string
description: The step to run with.
- execution_count:
+ execution-count:
type: integer
- execution_batch_size:
+ execution-batch-size:
type: integer
- optimization_target_metric:
+ optimization-target-metric:
type: string
- optimization_target_value:
- type: float
+ optimization-target-value:
+ type: number
engine:
type: string
type:
type: string
- enum:
- - bayesian_tpe
- - distributed
- - grid_search
- - manual_search
- - random_search
name:
type: string
description: The unique name for this task.
| valohai/valohai-yaml | d343bca91abcacba32ed9a5e0c978fbacfeed913 | diff --git a/tests/test_schemata.py b/tests/test_schemata.py
new file mode 100644
index 0000000..91d6f11
--- /dev/null
+++ b/tests/test_schemata.py
@@ -0,0 +1,14 @@
+from pathlib import Path
+
+from valohai_yaml.validation import SCHEMATA_DIRECTORY
+
+
+def test_schemata_has_no_underscores():
+ for yaml_path in Path(SCHEMATA_DIRECTORY).rglob("*.yaml"):
+ with yaml_path.open("r", encoding="utf-8") as f:
+ for lineno, line in enumerate(f, 1):
+ clean_line = line.partition("#")[0].strip()
+ if clean_line.endswith(":") and "_" in clean_line:
+ raise AssertionError(
+ f"Underscore in YAML key in {yaml_path!r}:{lineno}: {line!r}",
+ )
diff --git a/tests/test_task.py b/tests/test_task.py
index 42acaf4..7595524 100644
--- a/tests/test_task.py
+++ b/tests/test_task.py
@@ -1,4 +1,5 @@
from valohai_yaml.objs import Config, Task
+from valohai_yaml.objs.task import TaskType
from valohai_yaml.objs.variant_parameter import VariantParameterStyle
@@ -11,3 +12,12 @@ def test_tasks_parameters(task_config: Config):
if len(task.parameters) > 0:
assert task.parameters[0].name == "A"
assert isinstance(task.parameters[0].style, VariantParameterStyle)
+
+
+def test_task_additional_fields(task_config: Config):
+ task = task_config.tasks["task 4 logspace"]
+ assert task.execution_batch_size == 42
+ assert task.execution_count == 420
+ assert task.optimization_target_metric == "goodness"
+ assert task.optimization_target_value == 7.2
+ assert task.type == TaskType.RANDOM_SEARCH
| Normalize Task object keys to be kebab-case instead of snake_case
Everything else in our YAML is kebab-case, but due to a review oversight on my part the Task keys added in #98 are snake_case.
They should be made kebab-case.
Based on analytics, no one has used task definitions in YAML yet (and happily the snake_cased keys are also optional, and so used even less), so we can safely make this change before it's too late. | 0.0 | d343bca91abcacba32ed9a5e0c978fbacfeed913 | [
"tests/test_schemata.py::test_schemata_has_no_underscores",
"tests/test_task.py::test_task_additional_fields[direct]",
"tests/test_task.py::test_task_additional_fields[roundtrip]"
]
| [
"tests/test_task.py::test_tasks_parameters[direct]",
"tests/test_task.py::test_tasks_parameters[roundtrip]"
]
| {
"failed_lite_validators": [
"has_issue_reference",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-10-30 11:38:56+00:00 | mit | 6,190 |
|
valohai__valohai-yaml-132 | diff --git a/examples/task-example.yaml b/examples/task-example.yaml
index 1405282..160e18f 100644
--- a/examples/task-example.yaml
+++ b/examples/task-example.yaml
@@ -49,6 +49,8 @@
type: RANDOM-SEARCH # will be normalized
execution-batch-size: 42
execution-count: 420
+ maximum-queued-executions: 17
+ on-child-error: stop_all-AND_error # will be normalized
optimization-target-metric: goodness
optimization-target-value: 7.2
parameters:
diff --git a/valohai_yaml/objs/task.py b/valohai_yaml/objs/task.py
index eb00644..2ec1cc1 100644
--- a/valohai_yaml/objs/task.py
+++ b/valohai_yaml/objs/task.py
@@ -33,6 +33,23 @@ class TaskType(Enum):
return TaskType(value)
+class TaskOnChildError(Enum):
+ """Represents the possible actions that can be taken when a task's child fails."""
+
+ CONTINUE_AND_COMPLETE = "continue-and-complete"
+ CONTINUE_AND_ERROR = "continue-and-error"
+ STOP_ALL_AND_ERROR = "stop-all-and-error"
+
+ @classmethod
+ def cast(cls, value: TaskOnChildError | str | None) -> TaskOnChildError | None:
+ if not value:
+ return None
+ if isinstance(value, TaskOnChildError):
+ return value
+ value = str(value).lower().replace("_", "-")
+ return TaskOnChildError(value)
+
+
class Task(Item):
"""Represents a task definition."""
@@ -42,9 +59,11 @@ class Task(Item):
name: str
execution_count: int | None
execution_batch_size: int | None
+ maximum_queued_executions: int | None
optimization_target_metric: str | None
optimization_target_value: float | None
engine: str | None
+ on_child_error: TaskOnChildError | None
def __init__(
self,
@@ -55,9 +74,11 @@ class Task(Item):
parameters: list[VariantParameter] | None = None,
execution_count: int | None = None,
execution_batch_size: int | None = None,
+ maximum_queued_executions: int | None = None,
optimization_target_metric: str | None = None,
optimization_target_value: float | None = None,
engine: str | None = None,
+ on_child_error: TaskOnChildError | None = None,
stop_condition: str | None = None,
) -> None:
self.name = name
@@ -66,9 +87,11 @@ class Task(Item):
self.parameters = check_type_and_listify(parameters, VariantParameter)
self.execution_count = execution_count
self.execution_batch_size = execution_batch_size
+ self.maximum_queued_executions = maximum_queued_executions
self.optimization_target_metric = optimization_target_metric
self.optimization_target_value = optimization_target_value
self.engine = engine
+ self.on_child_error = TaskOnChildError.cast(on_child_error)
self.stop_condition = stop_condition
@classmethod
diff --git a/valohai_yaml/schema/task.yaml b/valohai_yaml/schema/task.yaml
index 7b84fb9..3c1365e 100644
--- a/valohai_yaml/schema/task.yaml
+++ b/valohai_yaml/schema/task.yaml
@@ -12,6 +12,8 @@ properties:
type: integer
execution-batch-size:
type: integer
+ maximum-queued-executions:
+ type: integer
optimization-target-metric:
type: string
optimization-target-value:
@@ -20,6 +22,8 @@ properties:
type: string
type:
type: string
+ on-child-error:
+ type: string
name:
type: string
description: The unique name for this task.
| valohai/valohai-yaml | 27bb15ed617895f384d5c4f4cc9eb8ff04a9d67e | diff --git a/tests/test_task.py b/tests/test_task.py
index 7595524..15af964 100644
--- a/tests/test_task.py
+++ b/tests/test_task.py
@@ -1,5 +1,5 @@
from valohai_yaml.objs import Config, Task
-from valohai_yaml.objs.task import TaskType
+from valohai_yaml.objs.task import TaskOnChildError, TaskType
from valohai_yaml.objs.variant_parameter import VariantParameterStyle
@@ -18,6 +18,8 @@ def test_task_additional_fields(task_config: Config):
task = task_config.tasks["task 4 logspace"]
assert task.execution_batch_size == 42
assert task.execution_count == 420
+ assert task.maximum_queued_executions == 17
+ assert task.on_child_error == TaskOnChildError.STOP_ALL_AND_ERROR
assert task.optimization_target_metric == "goodness"
assert task.optimization_target_value == 7.2
assert task.type == TaskType.RANDOM_SEARCH
| Define maximum queued executions for Task
It would be useful to be able to define the number of max queued executions in the `valohai.yaml`. | 0.0 | 27bb15ed617895f384d5c4f4cc9eb8ff04a9d67e | [
"tests/test_task.py::test_tasks_parameters[direct]",
"tests/test_task.py::test_tasks_parameters[roundtrip]",
"tests/test_task.py::test_task_additional_fields[direct]",
"tests/test_task.py::test_task_additional_fields[roundtrip]"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-10-30 13:18:38+00:00 | mit | 6,191 |
|
valohai__valohai-yaml-135 | diff --git a/examples/task-example.yaml b/examples/task-example.yaml
index 160e18f..6dc6f53 100644
--- a/examples/task-example.yaml
+++ b/examples/task-example.yaml
@@ -77,3 +77,21 @@
base: 10
distribution: uniform
integerify: False
+- task:
+ step: run training
+ name: parameter sets
+ type: manual_search
+ parameters:
+ - name: A
+ style: multiple
+ rules: {}
+ - name: B
+ style: multiple
+ rules: {}
+ parameter-sets:
+ - A: 5
+ B: 6
+ - A: 8
+ B: 9
+ - A: 72
+ B: 42
diff --git a/valohai_yaml/objs/task.py b/valohai_yaml/objs/task.py
index 2ec1cc1..a3d49ec 100644
--- a/valohai_yaml/objs/task.py
+++ b/valohai_yaml/objs/task.py
@@ -56,6 +56,7 @@ class Task(Item):
step: str
type: TaskType
parameters: list[VariantParameter]
+ parameter_sets: list[dict[str, Any]]
name: str
execution_count: int | None
execution_batch_size: int | None
@@ -72,6 +73,7 @@ class Task(Item):
step: str,
type: TaskType | str | None = None,
parameters: list[VariantParameter] | None = None,
+ parameter_sets: list[dict[str, Any]] | None = None,
execution_count: int | None = None,
execution_batch_size: int | None = None,
maximum_queued_executions: int | None = None,
@@ -85,6 +87,9 @@ class Task(Item):
self.step = step
self.type = TaskType.cast(type)
self.parameters = check_type_and_listify(parameters, VariantParameter)
+ self.parameter_sets = [
+ ps for ps in check_type_and_listify(parameter_sets, dict) if ps
+ ]
self.execution_count = execution_count
self.execution_batch_size = execution_batch_size
self.maximum_queued_executions = maximum_queued_executions
@@ -105,3 +110,5 @@ class Task(Item):
def lint(self, lint_result: LintResult, context: LintContext) -> None:
context = dict(context, task=self, object_type="task")
lint_expression(lint_result, context, "stop-condition", self.stop_condition)
+ if self.parameter_sets and self.type != TaskType.MANUAL_SEARCH:
+ lint_result.add_warning("Parameter sets only make sense with manual search")
diff --git a/valohai_yaml/schema/task.yaml b/valohai_yaml/schema/task.yaml
index 3c1365e..6d572db 100644
--- a/valohai_yaml/schema/task.yaml
+++ b/valohai_yaml/schema/task.yaml
@@ -37,3 +37,8 @@ properties:
"$ref": "./variant-param.json"
stop-condition:
type: string
+ parameter-sets:
+ type: array
+ description: Parameter sets for manual search mode.
+ items:
+ type: object
| valohai/valohai-yaml | fba4319af23e5a9512ce8a01ea1860c1fa481dbd | diff --git a/tests/test_task.py b/tests/test_task.py
index 15af964..d26f566 100644
--- a/tests/test_task.py
+++ b/tests/test_task.py
@@ -23,3 +23,12 @@ def test_task_additional_fields(task_config: Config):
assert task.optimization_target_metric == "goodness"
assert task.optimization_target_value == 7.2
assert task.type == TaskType.RANDOM_SEARCH
+
+
+def test_task_parameter_sets(task_config: Config):
+ task = task_config.tasks["parameter sets"]
+ assert task.parameter_sets == [
+ {"A": 5, "B": 6},
+ {"A": 8, "B": 9},
+ {"A": 72, "B": 42},
+ ]
| Task presets: allow configuring parameter sets for Manual Search
It should be possible to define also a manual search type Task in the `valohai.yaml` with the predefined parameter sets.
Related discussion: https://valohai.slack.com/archives/C02B7PSLQ3B/p1698836322106279 | 0.0 | fba4319af23e5a9512ce8a01ea1860c1fa481dbd | [
"tests/test_task.py::test_task_parameter_sets[direct]",
"tests/test_task.py::test_task_parameter_sets[roundtrip]"
]
| [
"tests/test_task.py::test_tasks_parameters[direct]",
"tests/test_task.py::test_tasks_parameters[roundtrip]",
"tests/test_task.py::test_task_additional_fields[direct]",
"tests/test_task.py::test_task_additional_fields[roundtrip]"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-11-01 14:04:25+00:00 | mit | 6,192 |
|
valohai__valohai-yaml-89 | diff --git a/examples/example1.yaml b/examples/example1.yaml
index e66c1a4..bf77bb2 100644
--- a/examples/example1.yaml
+++ b/examples/example1.yaml
@@ -57,3 +57,16 @@
description: List of decoding function types
type: string
default: gauss
+
+ - name: sql-query
+ type: string
+ default: SELECT * FROM mytable
+ widget: sql
+
+ - name: output-alias
+ type: string
+ default: my-alias
+ widget:
+ type: DatumAlias
+ settings:
+ width: 123
diff --git a/valohai_yaml/objs/parameter.py b/valohai_yaml/objs/parameter.py
index a0d12ed..a1f64e7 100644
--- a/valohai_yaml/objs/parameter.py
+++ b/valohai_yaml/objs/parameter.py
@@ -4,6 +4,7 @@ from typing import Any, Iterable, List, Optional, Union
from valohai_yaml.excs import InvalidType, ValidationErrors
from valohai_yaml.lint import LintResult
from valohai_yaml.objs.base import Item
+from valohai_yaml.objs.parameter_widget import ParameterWidget
from valohai_yaml.types import LintContext, SerializedDict
from valohai_yaml.utils import listify
@@ -48,7 +49,8 @@ class Parameter(Item):
pass_false_as: Optional[str] = None,
choices: Optional[Iterable[ValueAtomType]] = None,
multiple: Optional[Union[str, MultipleMode]] = None,
- multiple_separator: str = ','
+ multiple_separator: str = ',',
+ widget: Optional[ParameterWidget] = None,
) -> None:
self.name = name
self.type = type
@@ -62,6 +64,8 @@ class Parameter(Item):
self.choices = (list(choices) if choices else None)
self.multiple = MultipleMode.cast(multiple)
self.multiple_separator = str(multiple_separator or ',')
+ self.widget = widget
+
self.default = (listify(default) if self.multiple else default)
if self.type == 'flag':
self.optional = True
@@ -194,6 +198,13 @@ class Parameter(Item):
raise NotImplementedError(f'unknown multiple type {self.multiple!r}')
+ @classmethod
+ def parse(cls, data: SerializedDict) -> 'Parameter':
+ kwargs = data.copy()
+ if 'widget' in data:
+ kwargs['widget'] = ParameterWidget.parse(data['widget'])
+ return super().parse(kwargs)
+
def lint(
self,
lint_result: LintResult,
diff --git a/valohai_yaml/objs/parameter_widget.py b/valohai_yaml/objs/parameter_widget.py
new file mode 100644
index 0000000..0530b97
--- /dev/null
+++ b/valohai_yaml/objs/parameter_widget.py
@@ -0,0 +1,38 @@
+from typing import Optional, Union
+
+from valohai_yaml.objs.base import Item
+from valohai_yaml.types import SerializedDict
+
+
+class ParameterWidget(Item):
+ """An UI widget for editing parameter values."""
+
+ def __init__(
+ self,
+ *,
+ type: str,
+ settings: Optional[dict] = None,
+ ) -> None:
+ self.type = str(type).lower()
+ self.settings = dict(settings or {})
+
+ def serialize(self) -> Optional[Union[SerializedDict, str]]:
+ if self.settings:
+ return {
+ 'type': self.type,
+ 'settings': self.settings,
+ }
+ return self.type
+
+ @classmethod
+ def parse(cls, data: Union['ParameterWidget', dict, str]) -> 'ParameterWidget':
+ if isinstance(data, dict):
+ return cls(
+ type=data['type'],
+ settings=data.get('settings'),
+ )
+
+ if isinstance(data, cls):
+ return data
+
+ return cls(type=str(data))
diff --git a/valohai_yaml/schema/param-item.yaml b/valohai_yaml/schema/param-item.yaml
index 25c2334..e315907 100644
--- a/valohai_yaml/schema/param-item.yaml
+++ b/valohai_yaml/schema/param-item.yaml
@@ -78,3 +78,16 @@ properties:
description: |
The separator to use when interpolating multiple values into a command parameter.
Defaults to a comma.
+ widget:
+ oneOf:
+ - type: object
+ required:
+ - type
+ properties:
+ type:
+ type: string
+ settings:
+ type: object
+ - type: string
+ description: |
+ UI widget used for editing parameter values
| valohai/valohai-yaml | b3a500a45d08e8b835e0946ef210c2a2f0fe1001 | diff --git a/tests/test_step_parsing.py b/tests/test_step_parsing.py
index 4eb3bdf..406889e 100644
--- a/tests/test_step_parsing.py
+++ b/tests/test_step_parsing.py
@@ -26,7 +26,7 @@ def test_parse(example1_config):
# test that we parsed all params
parameters = step.parameters
- assert len(parameters) == 7
+ assert len(parameters) == 9
# test that we can access them by name
assert parameters['seed'].default == 1
assert parameters['decoder-spec'].default == 'gauss'
@@ -39,6 +39,8 @@ def test_parse(example1_config):
'encoder-layers',
'denoising-cost-x',
'decoder-spec',
+ 'sql-query',
+ 'output-alias',
]
# test that `get_step_by` works
@@ -154,3 +156,12 @@ def test_timeouts(timeouts_config):
def test_bling(example1_config: Config) -> None:
assert example1_config.steps['run training'].category == "Training"
assert example1_config.steps['run training'].icon == "https://valohai.com/assets/img/valohai-logo.svg"
+
+
+def test_widget(example1_config: Config) -> None:
+ parameters = example1_config.steps['run training'].parameters
+ assert parameters['sql-query'].widget and parameters['sql-query'].widget.type == "sql"
+ widget = parameters['output-alias'].widget
+ assert widget and widget.type == "datumalias"
+ assert widget and widget.settings and widget.settings["width"] == 123
+ assert parameters['decoder-spec'].widget is None
| Support for parameter UI widgets (YAML)
Support in YAML to ask for a custom UI widget for parameter editing like SQL or DatumAlias.
Example UI:

Example YAML:
```
- step:
name: snowflake-query
image: valohai/dbconnectors
command: python query.py {parameters}
icon: https://valohai.com/img/orig/SNOW-35164165.png
category: Database query
parameters:
- name: SQLquery
type: string
default: SELECT * FROM table
widget: sql
- name: datum_alias
type: string
widget: datumalias
``` | 0.0 | b3a500a45d08e8b835e0946ef210c2a2f0fe1001 | [
"tests/test_step_parsing.py::test_parse[direct]",
"tests/test_step_parsing.py::test_parse[roundtrip]",
"tests/test_step_parsing.py::test_widget[direct]",
"tests/test_step_parsing.py::test_widget[roundtrip]"
]
| [
"tests/test_step_parsing.py::test_parse_inputs[direct]",
"tests/test_step_parsing.py::test_parse_inputs[roundtrip]",
"tests/test_step_parsing.py::test_parse_input_defaults[direct]",
"tests/test_step_parsing.py::test_parse_input_defaults[roundtrip]",
"tests/test_step_parsing.py::test_boolean_param_parse[direct]",
"tests/test_step_parsing.py::test_boolean_param_parse[roundtrip]",
"tests/test_step_parsing.py::test_boolean_pass_as_param_parse[direct]",
"tests/test_step_parsing.py::test_boolean_pass_as_param_parse[roundtrip]",
"tests/test_step_parsing.py::test_optional_default_param_parse[direct]",
"tests/test_step_parsing.py::test_optional_default_param_parse[roundtrip]",
"tests/test_step_parsing.py::test_mount_parse[direct]",
"tests/test_step_parsing.py::test_mount_parse[roundtrip]",
"tests/test_step_parsing.py::test_parse_environment_variables[direct]",
"tests/test_step_parsing.py::test_parse_environment_variables[roundtrip]",
"tests/test_step_parsing.py::test_parse_environment[direct]",
"tests/test_step_parsing.py::test_parse_environment[roundtrip]",
"tests/test_step_parsing.py::test_parse_step_description[direct]",
"tests/test_step_parsing.py::test_parse_step_description[roundtrip]",
"tests/test_step_parsing.py::test_input_extras[direct]",
"tests/test_step_parsing.py::test_input_extras[roundtrip]",
"tests/test_step_parsing.py::test_input_keep_directories[KeepDirectories.NONE-KeepDirectories.NONE]",
"tests/test_step_parsing.py::test_input_keep_directories[KeepDirectories.SUFFIX-KeepDirectories.SUFFIX]",
"tests/test_step_parsing.py::test_input_keep_directories[KeepDirectories.FULL-KeepDirectories.FULL]",
"tests/test_step_parsing.py::test_input_keep_directories[full-KeepDirectories.FULL]",
"tests/test_step_parsing.py::test_input_keep_directories[False-KeepDirectories.NONE]",
"tests/test_step_parsing.py::test_input_keep_directories[True-KeepDirectories.FULL]",
"tests/test_step_parsing.py::test_input_keep_directories[suffix-KeepDirectories.SUFFIX]",
"tests/test_step_parsing.py::test_timeouts[direct]",
"tests/test_step_parsing.py::test_timeouts[roundtrip]",
"tests/test_step_parsing.py::test_bling[direct]",
"tests/test_step_parsing.py::test_bling[roundtrip]"
]
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_media",
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-01-30 12:29:30+00:00 | mit | 6,193 |
|
valohai__valohai-yaml-94 | diff --git a/valohai_yaml/lint.py b/valohai_yaml/lint.py
index 52ef31c..0df3be0 100644
--- a/valohai_yaml/lint.py
+++ b/valohai_yaml/lint.py
@@ -1,5 +1,6 @@
from typing import Iterator, List, Optional
+import yaml as pyyaml
from jsonschema.exceptions import relevance
from valohai_yaml.excs import ValidationError
@@ -21,6 +22,9 @@ class LintResult:
def add_warning(self, message: str, location: None = None, exception: Optional[Exception] = None) -> None:
self.messages.append({'type': 'warning', 'message': message, 'location': location, 'exception': exception})
+ def add_hint(self, message: str, location: None = None, exception: Optional[Exception] = None) -> None:
+ self.messages.append({'type': 'hint', 'message': message, 'location': location, 'exception': exception})
+
@property
def warning_count(self) -> int:
return sum(1 for m in self.messages if m['type'] == 'warning')
@@ -37,6 +41,10 @@ class LintResult:
def errors(self) -> Iterator[LintResultMessage]:
return (m for m in self.messages if m['type'] == 'error')
+ @property
+ def hints(self) -> Iterator[LintResultMessage]:
+ return (m for m in self.messages if m['type'] == 'hint')
+
def is_valid(self) -> bool:
return (self.warning_count == 0 and self.error_count == 0)
@@ -60,7 +68,17 @@ def lint_file(file_path: str) -> LintResult:
def lint(yaml: YamlReadable) -> LintResult:
lr = LintResult()
- data = read_yaml(yaml)
+ try:
+ data = read_yaml(yaml)
+ except pyyaml.YAMLError as err:
+ if hasattr(err, 'problem_mark'):
+ mark = err.problem_mark
+ indent_error = f"Indentation Error at line {mark.line + 1}, column {mark.column + 1}"
+ lr.add_error(indent_error)
+ else:
+ lr.add_error(str(err))
+ return lr
+
validator = get_validator()
errors = sorted(
validator.iter_errors(data),
@@ -79,6 +97,14 @@ def lint(yaml: YamlReadable) -> LintResult:
styled_message = style(error.message, fg='red')
styled_path = style('.'.join(obj_path), bold=True)
lr.add_error(f' {styled_validator} validation on {styled_schema_path}: {styled_message} ({styled_path})')
+ # when path has only 2 nodes. it means it has problem in main steps/pipelines/endpoints objects
+ if len(error.path) == 2 and not error.instance:
+ styled_hint = style(
+ "File contains valid YAML but there might be an indentation "
+ f"error in following configuration: {styled_path}",
+ fg='blue',
+ )
+ lr.add_hint(styled_hint)
if len(errors) > 0:
return lr
| valohai/valohai-yaml | 00f85faa85b3ee5c45a04d6447f7b6902ecc2388 | diff --git a/tests/error_examples/invalid-YAML-indentation.yaml b/tests/error_examples/invalid-YAML-indentation.yaml
new file mode 100644
index 0000000..b49c958
--- /dev/null
+++ b/tests/error_examples/invalid-YAML-indentation.yaml
@@ -0,0 +1,7 @@
+- step:
+ name: outdented
+ image: python:3.7
+ inputs: []
+ command:
+ - pip install -r requirements.txt
+ - python ./test.py {parameters}
diff --git a/tests/error_examples/invalid-indentation-with-valid-YAML.yaml b/tests/error_examples/invalid-indentation-with-valid-YAML.yaml
new file mode 100644
index 0000000..97489fe
--- /dev/null
+++ b/tests/error_examples/invalid-indentation-with-valid-YAML.yaml
@@ -0,0 +1,7 @@
+- step:
+ name: valid-yaml-but-unindented
+ image: python:3.7
+ inputs: []
+ command:
+ - pip install -r requirements.txt
+ - python ./test.py {parameters}
diff --git a/tests/test_linter.py b/tests/test_linter.py
index b6a6a67..19950af 100644
--- a/tests/test_linter.py
+++ b/tests/test_linter.py
@@ -2,7 +2,7 @@ from itertools import chain
import pytest
-from tests.utils import get_warning_example_path
+from tests.utils import get_error_example_path, get_warning_example_path
from valohai_yaml.lint import lint_file
@@ -22,3 +22,16 @@ def test_invalid_parameter_default(file, expected_message):
items = lint_file(get_warning_example_path(file))
messages = [item['message'] for item in chain(items.warnings, items.errors)]
assert any(expected_message in message for message in messages), messages # pragma: no branch
+
+
[email protected]('file, expected_message', [
+ ('invalid-indentation-with-valid-YAML.yaml',
+ '\x1b[34mFile contains valid YAML but there '
+ 'might be an indentation error in following '
+ 'configuration: \x1b[1m0.step\x1b'),
+ ('invalid-YAML-indentation.yaml', 'Indentation Error at line 3, column 10'),
+])
+def test_invalid_indentation(file, expected_message):
+ items = lint_file(get_error_example_path(file))
+ messages = [item['message'] for item in chain(items.hints, items.errors)]
+ assert any(expected_message in message for message in messages), messages # pragma: no branch
| Indentation errors are cryptically linted
`vh lint` throws an error if the valohai.yaml file has lines that are not properly indented.
The error message is cryptic:
`error: Type validation on pipeline: None is not of type 'object' (2.pipeline)`
The error message should clearly say that the issue is in indentation.
Below an example of a pipeline that fails. But if you indent everything under pipeline (lineno 2->) it's valid.
```yaml
- pipeline:
name: mypipeline
nodes:
- name: validation-node
type: task
step: validate
- name: ingest-node
type: task
step: ingest
override:
inputs:
- name: image
edges:
- [validation-node.parameter.image, ingest-node.parameter.image]
``` | 0.0 | 00f85faa85b3ee5c45a04d6447f7b6902ecc2388 | [
"tests/test_linter.py::test_invalid_indentation[invalid-indentation-with-valid-YAML.yaml-\\x1b[34mFile",
"tests/test_linter.py::test_invalid_indentation[invalid-YAML-indentation.yaml-Indentation"
]
| [
"tests/test_linter.py::test_optional_flag",
"tests/test_linter.py::test_invalid_parameter_default[invalid-string-parameter-default.yaml-is",
"tests/test_linter.py::test_invalid_parameter_default[invalid-numeric-parameter-default.yaml-is",
"tests/test_linter.py::test_invalid_parameter_default[invalid-numeric-range-parameter-default.yaml-greater"
]
| {
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-05-15 10:47:34+00:00 | mit | 6,194 |
|
vcs-python__vcspull-387 | diff --git a/CHANGES b/CHANGES
index dda4e8c..827bc78 100644
--- a/CHANGES
+++ b/CHANGES
@@ -22,6 +22,23 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force
### What's new
- Refreshed logo
+- `vcspull sync`:
+
+ - Syncing will now skip to the next repos if an error is encountered
+
+ - Learned `--exit-on-error` / `-x`
+
+ Usage:
+
+ ```console
+ $ vcspull sync --exit-on-error grako django
+ ```
+
+ Print traceback for errored repos:
+
+ ```console
+ $ vcspull --log-level DEBUG sync --exit-on-error grako django
+ ```
### Development
@@ -33,6 +50,10 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force
- Add [flake8-bugbear](https://github.com/PyCQA/flake8-bugbear) (#379)
- Add [flake8-comprehensions](https://github.com/adamchainz/flake8-comprehensions) (#380)
+### Testing
+
+- Add CLI tests (#387)
+
### Documentation
- Render changelog in sphinx-autoissues (#378)
diff --git a/docs/cli/sync.md b/docs/cli/sync.md
index 55283d0..5153ef9 100644
--- a/docs/cli/sync.md
+++ b/docs/cli/sync.md
@@ -4,6 +4,22 @@
# vcspull sync
+## Error handling
+
+As of 1.13.x, vcspull will continue to the next repo if an error is encountered when syncing multiple repos.
+
+To imitate the old behavior, use `--exit-on-error` / `-x`:
+
+```console
+$ vcspull sync --exit-on-error grako django
+```
+
+Print traceback for errored repos:
+
+```console
+$ vcspull --log-level DEBUG sync --exit-on-error grako django
+```
+
```{eval-rst}
.. click:: vcspull.cli.sync:sync
:prog: vcspull sync
diff --git a/src/vcspull/cli/__init__.py b/src/vcspull/cli/__init__.py
index 010196b..1d36ef0 100644
--- a/src/vcspull/cli/__init__.py
+++ b/src/vcspull/cli/__init__.py
@@ -19,8 +19,8 @@ log = logging.getLogger(__name__)
@click.group(
context_settings={
+ "obj": {},
"help_option_names": ["-h", "--help"],
- "allow_interspersed_args": True,
}
)
@click.option(
diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py
index 76ffe63..99280f1 100644
--- a/src/vcspull/cli/sync.py
+++ b/src/vcspull/cli/sync.py
@@ -59,6 +59,9 @@ def clamp(n, _min, _max):
return max(_min, min(n, _max))
+EXIT_ON_ERROR_MSG = "Exiting via error (--exit-on-error passed)"
+
+
@click.command(name="sync")
@click.argument(
"repo_terms", type=click.STRING, nargs=-1, shell_complete=get_repo_completions
@@ -71,7 +74,15 @@ def clamp(n, _min, _max):
help="Specify config",
shell_complete=get_config_file_completions,
)
-def sync(repo_terms, config):
[email protected](
+ "exit_on_error",
+ "--exit-on-error",
+ "-x",
+ is_flag=True,
+ default=False,
+ help="Exit immediately when encountering an error syncing multiple repos",
+)
+def sync(repo_terms, config, exit_on_error: bool) -> None:
if config:
configs = load_configs([config])
else:
@@ -95,7 +106,19 @@ def sync(repo_terms, config):
else:
found_repos = configs
- list(map(update_repo, found_repos))
+ for repo in found_repos:
+ try:
+ update_repo(repo)
+ except Exception:
+ click.echo(
+ f'Failed syncing {repo.get("name")}',
+ )
+ if log.isEnabledFor(logging.DEBUG):
+ import traceback
+
+ traceback.print_exc()
+ if exit_on_error:
+ raise click.ClickException(EXIT_ON_ERROR_MSG)
def progress_cb(output, timestamp):
diff --git a/src/vcspull/log.py b/src/vcspull/log.py
index fe69e02..7538b5c 100644
--- a/src/vcspull/log.py
+++ b/src/vcspull/log.py
@@ -29,7 +29,7 @@ def setup_logger(log=None, level="INFO"):
Parameters
----------
- log : :py:class:`Logger`
+ log : :py:class:`logging.Logger`
instance of logger
"""
if not log:
| vcs-python/vcspull | ea44ca60bb0debf54cba7671c0e3c25f40274ed3 | diff --git a/tests/conftest.py b/tests/conftest.py
index d1aa082..da0d24a 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -71,7 +71,7 @@ def git_repo_kwargs(repos_path: pathlib.Path, git_dummy_repo_dir):
"""Return kwargs for :func:`create_project`."""
return {
"url": "git+file://" + git_dummy_repo_dir,
- "parent_dir": str(repos_path),
+ "dir": str(repos_path / "repo_name"),
"name": "repo_name",
}
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 88cbb1f..afe6612 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1,14 +1,184 @@
+import pathlib
+import typing as t
+
import pytest
+import yaml
from click.testing import CliRunner
+from libvcs.sync.git import GitSync
from vcspull.cli import cli
+from vcspull.cli.sync import EXIT_ON_ERROR_MSG
+
+
+def test_sync_cli_non_existent(tmp_path: pathlib.Path) -> None:
+ runner = CliRunner()
+ with runner.isolated_filesystem(temp_dir=tmp_path):
+ result = runner.invoke(cli, ["sync", "hi"])
+ assert result.exit_code == 0
+ assert "" in result.output
+
+
+def test_sync(
+ home_path: pathlib.Path,
+ config_path: pathlib.Path,
+ tmp_path: pathlib.Path,
+ git_repo: GitSync,
+) -> None:
+ runner = CliRunner()
+ with runner.isolated_filesystem(temp_dir=tmp_path):
+ config = {
+ "~/github_projects/": {
+ "my_git_repo": {
+ "url": f"git+file://{git_repo.dir}",
+ "remotes": {"test_remote": f"git+file://{git_repo.dir}"},
+ },
+ "broken_repo": {
+ "url": f"git+file://{git_repo.dir}",
+ "remotes": {"test_remote": "git+file://non-existent-remote"},
+ },
+ }
+ }
+ yaml_config = config_path / ".vcspull.yaml"
+ yaml_config_data = yaml.dump(config, default_flow_style=False)
+ yaml_config.write_text(yaml_config_data, encoding="utf-8")
+
+ # CLI can sync
+ result = runner.invoke(cli, ["sync", "my_git_repo"])
+ assert result.exit_code == 0
+ output = "".join(list(result.output))
+ assert "my_git_repo" in output
+
+
+if t.TYPE_CHECKING:
+ from typing_extensions import TypeAlias
+ ExpectedOutput: TypeAlias = t.Optional[t.Union[str, t.List[str]]]
[email protected](reason="todo")
-def test_command_line(self):
+
+class SyncBrokenFixture(t.NamedTuple):
+ test_id: str
+ sync_args: list[str]
+ expected_exit_code: int
+ expected_in_output: "ExpectedOutput" = None
+ expected_not_in_output: "ExpectedOutput" = None
+
+
+SYNC_BROKEN_REPO_FIXTURES = [
+ SyncBrokenFixture(
+ test_id="normal-checkout",
+ sync_args=["my_git_repo"],
+ expected_exit_code=0,
+ expected_in_output="Already on 'master'",
+ ),
+ SyncBrokenFixture(
+ test_id="normal-checkout--exit-on-error",
+ sync_args=["my_git_repo", "--exit-on-error"],
+ expected_exit_code=0,
+ expected_in_output="Already on 'master'",
+ ),
+ SyncBrokenFixture(
+ test_id="normal-checkout--x",
+ sync_args=["my_git_repo", "-x"],
+ expected_exit_code=0,
+ expected_in_output="Already on 'master'",
+ ),
+ SyncBrokenFixture(
+ test_id="normal-first-broken",
+ sync_args=["non_existent_repo", "my_git_repo"],
+ expected_exit_code=0,
+ expected_not_in_output=EXIT_ON_ERROR_MSG,
+ ),
+ SyncBrokenFixture(
+ test_id="normal-last-broken",
+ sync_args=["my_git_repo", "non_existent_repo"],
+ expected_exit_code=0,
+ expected_not_in_output=EXIT_ON_ERROR_MSG,
+ ),
+ SyncBrokenFixture(
+ test_id="exit-on-error--exit-on-error-first-broken",
+ sync_args=["non_existent_repo", "my_git_repo", "--exit-on-error"],
+ expected_exit_code=1,
+ expected_in_output=EXIT_ON_ERROR_MSG,
+ ),
+ SyncBrokenFixture(
+ test_id="exit-on-error--x-first-broken",
+ sync_args=["non_existent_repo", "my_git_repo", "-x"],
+ expected_exit_code=1,
+ expected_in_output=EXIT_ON_ERROR_MSG,
+ expected_not_in_output="master",
+ ),
+ #
+ # Verify ordering
+ #
+ SyncBrokenFixture(
+ test_id="exit-on-error--exit-on-error-last-broken",
+ sync_args=["my_git_repo", "non_existent_repo", "-x"],
+ expected_exit_code=1,
+ expected_in_output=[EXIT_ON_ERROR_MSG, "Already on 'master'"],
+ ),
+ SyncBrokenFixture(
+ test_id="exit-on-error--x-last-item",
+ sync_args=["my_git_repo", "non_existent_repo", "--exit-on-error"],
+ expected_exit_code=1,
+ expected_in_output=[EXIT_ON_ERROR_MSG, "Already on 'master'"],
+ ),
+]
+
+
[email protected](
+ list(SyncBrokenFixture._fields),
+ SYNC_BROKEN_REPO_FIXTURES,
+ ids=[test.test_id for test in SYNC_BROKEN_REPO_FIXTURES],
+)
+def test_sync_broken(
+ home_path: pathlib.Path,
+ config_path: pathlib.Path,
+ tmp_path: pathlib.Path,
+ git_repo: GitSync,
+ test_id: str,
+ sync_args: list[str],
+ expected_exit_code: int,
+ expected_in_output: "ExpectedOutput",
+ expected_not_in_output: "ExpectedOutput",
+) -> None:
runner = CliRunner()
- result = runner.invoke(cli, ["sync", "hi"])
- assert result.exit_code == 0
- assert "Debug mode is on" in result.output
- assert "Syncing" in result.output
+
+ github_projects = home_path / "github_projects"
+ my_git_repo = github_projects / "my_git_repo"
+ if my_git_repo.is_dir():
+ my_git_repo.rmdir()
+
+ with runner.isolated_filesystem(temp_dir=tmp_path):
+ config = {
+ "~/github_projects/": {
+ "my_git_repo": {
+ "url": f"git+file://{git_repo.dir}",
+ "remotes": {"test_remote": f"git+file://{git_repo.dir}"},
+ },
+ "non_existent_repo": {
+ "url": "git+file:///dev/null",
+ },
+ }
+ }
+ yaml_config = config_path / ".vcspull.yaml"
+ yaml_config_data = yaml.dump(config, default_flow_style=False)
+ yaml_config.write_text(yaml_config_data, encoding="utf-8")
+
+ # CLI can sync
+ assert isinstance(sync_args, list)
+ result = runner.invoke(cli, ["sync", *sync_args])
+ assert result.exit_code == expected_exit_code
+ output = "".join(list(result.output))
+
+ if expected_in_output is not None:
+ if isinstance(expected_in_output, str):
+ expected_in_output = [expected_in_output]
+ for needle in expected_in_output:
+ assert needle in output
+
+ if expected_not_in_output is not None:
+ if isinstance(expected_not_in_output, str):
+ expected_not_in_output = [expected_not_in_output]
+ for needle in expected_not_in_output:
+ assert needle not in output
| Continue on error
#361
`--continue-on-error` / etc. (see what other apps use for flags to continue on error) | 0.0 | ea44ca60bb0debf54cba7671c0e3c25f40274ed3 | [
"tests/test_cli.py::test_sync_cli_non_existent",
"tests/test_cli.py::test_sync",
"tests/test_cli.py::test_sync_broken[normal-checkout]",
"tests/test_cli.py::test_sync_broken[normal-checkout--exit-on-error]",
"tests/test_cli.py::test_sync_broken[normal-checkout--x]",
"tests/test_cli.py::test_sync_broken[normal-first-broken]",
"tests/test_cli.py::test_sync_broken[normal-last-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--exit-on-error-first-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--x-first-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--exit-on-error-last-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--x-last-item]"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_issue_reference",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-09-25 16:25:43+00:00 | mit | 6,195 |
|
vcs-python__vcspull-394 | diff --git a/CHANGES b/CHANGES
index 827bc78..76b3566 100644
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,10 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force
- Refreshed logo
- `vcspull sync`:
+ - Terms with no match in config will show a notice (#394)
+
+ > No repo found in config(s) for "non_existent_repo"
+
- Syncing will now skip to the next repos if an error is encountered
- Learned `--exit-on-error` / `-x`
diff --git a/docs/cli/sync.md b/docs/cli/sync.md
index 5153ef9..1cc636f 100644
--- a/docs/cli/sync.md
+++ b/docs/cli/sync.md
@@ -6,9 +6,35 @@
## Error handling
+### Repos not found in config
+
+As of 1.13.x, if you enter a repo term (or terms) that aren't found throughout
+your configurations, it will show a warning:
+
+```console
+$ vcspull sync non_existent_repo
+No repo found in config(s) for "non_existent_repo"
+```
+
+```console
+$ vcspull sync non_existent_repo existing_repo
+No repo found in config(s) for "non_existent_repo"
+```
+
+```console
+$ vcspull sync non_existent_repo existing_repo another_repo_not_in_config
+No repo found in config(s) for "non_existent_repo"
+No repo found in config(s) for "another_repo_not_in_config"
+```
+
+Since syncing terms are treated as a filter rather than a lookup, the message is
+considered a warning, so will not exit even if `--exit-on-error` flag is used.
+
+### Syncing
+
As of 1.13.x, vcspull will continue to the next repo if an error is encountered when syncing multiple repos.
-To imitate the old behavior, use `--exit-on-error` / `-x`:
+To imitate the old behavior, the `--exit-on-error` / `-x` flag:
```console
$ vcspull sync --exit-on-error grako django
diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py
index 99280f1..f91328e 100644
--- a/src/vcspull/cli/sync.py
+++ b/src/vcspull/cli/sync.py
@@ -60,6 +60,7 @@ def clamp(n, _min, _max):
EXIT_ON_ERROR_MSG = "Exiting via error (--exit-on-error passed)"
+NO_REPOS_FOR_TERM_MSG = 'No repo found in config(s) for "{name}"'
@click.command(name="sync")
@@ -100,6 +101,9 @@ def sync(repo_terms, config, exit_on_error: bool) -> None:
name = repo_term
# collect the repos from the config files
+ found = filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name)
+ if len(found) == 0:
+ click.echo(NO_REPOS_FOR_TERM_MSG.format(name=name))
found_repos.extend(
filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name)
)
| vcs-python/vcspull | 2e7844c9ce0dbeb23aff0aa1859a645592191c2a | diff --git a/tests/test_cli.py b/tests/test_cli.py
index cd6a808..00fd9f5 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -9,15 +9,94 @@ from click.testing import CliRunner
from libvcs.sync.git import GitSync
from vcspull.cli import cli
-from vcspull.cli.sync import EXIT_ON_ERROR_MSG
+from vcspull.cli.sync import EXIT_ON_ERROR_MSG, NO_REPOS_FOR_TERM_MSG
+if t.TYPE_CHECKING:
+ from typing_extensions import TypeAlias
+
+ ExpectedOutput: TypeAlias = t.Optional[t.Union[str, t.List[str]]]
+
+
+class SyncCLINonExistentRepo(t.NamedTuple):
+ test_id: str
+ sync_args: list[str]
+ expected_exit_code: int
+ expected_in_output: "ExpectedOutput" = None
+ expected_not_in_output: "ExpectedOutput" = None
+
+
+SYNC_CLI_EXISTENT_REPO_FIXTURES = [
+ SyncCLINonExistentRepo(
+ test_id="exists",
+ sync_args=["my_git_project"],
+ expected_exit_code=0,
+ expected_in_output="Already on 'master'",
+ expected_not_in_output=NO_REPOS_FOR_TERM_MSG.format(name="my_git_repo"),
+ ),
+ SyncCLINonExistentRepo(
+ test_id="non-existent-only",
+ sync_args=["this_isnt_in_the_config"],
+ expected_exit_code=0,
+ expected_in_output=NO_REPOS_FOR_TERM_MSG.format(name="this_isnt_in_the_config"),
+ ),
+ SyncCLINonExistentRepo(
+ test_id="non-existent-mixed",
+ sync_args=["this_isnt_in_the_config", "my_git_project", "another"],
+ expected_exit_code=0,
+ expected_in_output=[
+ NO_REPOS_FOR_TERM_MSG.format(name="this_isnt_in_the_config"),
+ NO_REPOS_FOR_TERM_MSG.format(name="another"),
+ ],
+ expected_not_in_output=NO_REPOS_FOR_TERM_MSG.format(name="my_git_repo"),
+ ),
+]
+
+
[email protected](
+ list(SyncCLINonExistentRepo._fields),
+ SYNC_CLI_EXISTENT_REPO_FIXTURES,
+ ids=[test.test_id for test in SYNC_CLI_EXISTENT_REPO_FIXTURES],
+)
+def test_sync_cli_repo_term_non_existent(
+ user_path: pathlib.Path,
+ config_path: pathlib.Path,
+ tmp_path: pathlib.Path,
+ git_repo: GitSync,
+ test_id: str,
+ sync_args: list[str],
+ expected_exit_code: int,
+ expected_in_output: "ExpectedOutput",
+ expected_not_in_output: "ExpectedOutput",
+) -> None:
+ config = {
+ "~/github_projects/": {
+ "my_git_project": {
+ "url": f"git+file://{git_repo.dir}",
+ "remotes": {"test_remote": f"git+file://{git_repo.dir}"},
+ },
+ }
+ }
+ yaml_config = config_path / ".vcspull.yaml"
+ yaml_config_data = yaml.dump(config, default_flow_style=False)
+ yaml_config.write_text(yaml_config_data, encoding="utf-8")
-def test_sync_cli_non_existent(tmp_path: pathlib.Path) -> None:
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path):
- result = runner.invoke(cli, ["sync", "hi"])
- assert result.exit_code == 0
- assert "" in result.output
+ result = runner.invoke(cli, ["sync", *sync_args])
+ assert result.exit_code == expected_exit_code
+ output = "".join(list(result.output))
+
+ if expected_in_output is not None:
+ if isinstance(expected_in_output, str):
+ expected_in_output = [expected_in_output]
+ for needle in expected_in_output:
+ assert needle in output
+
+ if expected_not_in_output is not None:
+ if isinstance(expected_not_in_output, str):
+ expected_not_in_output = [expected_not_in_output]
+ for needle in expected_not_in_output:
+ assert needle not in output
def test_sync(
@@ -51,12 +130,6 @@ def test_sync(
assert "my_git_repo" in output
-if t.TYPE_CHECKING:
- from typing_extensions import TypeAlias
-
- ExpectedOutput: TypeAlias = t.Optional[t.Union[str, t.List[str]]]
-
-
class SyncBrokenFixture(t.NamedTuple):
test_id: str
sync_args: list[str]
@@ -86,25 +159,25 @@ SYNC_BROKEN_REPO_FIXTURES = [
),
SyncBrokenFixture(
test_id="normal-first-broken",
- sync_args=["non_existent_repo", "my_git_repo"],
+ sync_args=["my_git_repo_not_found", "my_git_repo"],
expected_exit_code=0,
expected_not_in_output=EXIT_ON_ERROR_MSG,
),
SyncBrokenFixture(
test_id="normal-last-broken",
- sync_args=["my_git_repo", "non_existent_repo"],
+ sync_args=["my_git_repo", "my_git_repo_not_found"],
expected_exit_code=0,
expected_not_in_output=EXIT_ON_ERROR_MSG,
),
SyncBrokenFixture(
test_id="exit-on-error--exit-on-error-first-broken",
- sync_args=["non_existent_repo", "my_git_repo", "--exit-on-error"],
+ sync_args=["my_git_repo_not_found", "my_git_repo", "--exit-on-error"],
expected_exit_code=1,
expected_in_output=EXIT_ON_ERROR_MSG,
),
SyncBrokenFixture(
test_id="exit-on-error--x-first-broken",
- sync_args=["non_existent_repo", "my_git_repo", "-x"],
+ sync_args=["my_git_repo_not_found", "my_git_repo", "-x"],
expected_exit_code=1,
expected_in_output=EXIT_ON_ERROR_MSG,
expected_not_in_output="master",
@@ -114,13 +187,13 @@ SYNC_BROKEN_REPO_FIXTURES = [
#
SyncBrokenFixture(
test_id="exit-on-error--exit-on-error-last-broken",
- sync_args=["my_git_repo", "non_existent_repo", "-x"],
+ sync_args=["my_git_repo", "my_git_repo_not_found", "-x"],
expected_exit_code=1,
expected_in_output=[EXIT_ON_ERROR_MSG, "Already on 'master'"],
),
SyncBrokenFixture(
test_id="exit-on-error--x-last-item",
- sync_args=["my_git_repo", "non_existent_repo", "--exit-on-error"],
+ sync_args=["my_git_repo", "my_git_repo_not_found", "--exit-on-error"],
expected_exit_code=1,
expected_in_output=[EXIT_ON_ERROR_MSG, "Already on 'master'"],
),
@@ -157,7 +230,7 @@ def test_sync_broken(
"url": f"git+file://{git_repo.dir}",
"remotes": {"test_remote": f"git+file://{git_repo.dir}"},
},
- "non_existent_repo": {
+ "my_git_repo_not_found": {
"url": "git+file:///dev/null",
},
}
| `$ vcspull sync`: Print message if repo not in config
```console
$ vcspull sync repo-not-in-config
```
Should notify user repo not found | 0.0 | 2e7844c9ce0dbeb23aff0aa1859a645592191c2a | [
"tests/test_cli.py::test_sync_cli_repo_term_non_existent[exists]",
"tests/test_cli.py::test_sync_cli_repo_term_non_existent[non-existent-only]",
"tests/test_cli.py::test_sync_cli_repo_term_non_existent[non-existent-mixed]",
"tests/test_cli.py::test_sync",
"tests/test_cli.py::test_sync_broken[normal-checkout]",
"tests/test_cli.py::test_sync_broken[normal-checkout--exit-on-error]",
"tests/test_cli.py::test_sync_broken[normal-checkout--x]",
"tests/test_cli.py::test_sync_broken[normal-first-broken]",
"tests/test_cli.py::test_sync_broken[normal-last-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--exit-on-error-first-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--x-first-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--exit-on-error-last-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--x-last-item]"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-09-25 21:02:22+00:00 | mit | 6,196 |
|
vcs-python__vcspull-395 | diff --git a/CHANGES b/CHANGES
index 76b3566..c6dbb23 100644
--- a/CHANGES
+++ b/CHANGES
@@ -24,6 +24,29 @@ $ pipx install --suffix=@next 'vcspull' --pip-args '\--pre' --force
- Refreshed logo
- `vcspull sync`:
+ - Empty command will now show help output
+
+ ```console
+ $ vcspull sync
+ Usage: vcspull sync [OPTIONS] [REPO_TERMS]...
+
+ Options:
+ -c, --config PATH Specify config
+ -x, --exit-on-error Exit immediately when encountering an error syncing
+ multiple repos
+ -h, --help Show this message and exit.
+ ```
+
+ To achieve the equivalent behavior of syncing all repos, pass `'*'`:
+
+ ```console
+ $ vcspull sync '*'
+ ```
+
+ Depending on how shell escaping works in your shell setup with [wild card / asterisk], you may not need to quote `*`.
+
+ [wild card / asterisk]: https://tldp.org/LDP/abs/html/special-chars.html#:~:text=wild%20card%20%5Basterisk%5D.
+
- Terms with no match in config will show a notice (#394)
> No repo found in config(s) for "non_existent_repo"
diff --git a/docs/cli/sync.md b/docs/cli/sync.md
index 1cc636f..81716b9 100644
--- a/docs/cli/sync.md
+++ b/docs/cli/sync.md
@@ -4,6 +4,41 @@
# vcspull sync
+## Filtering repos
+
+As of 1.13.x, `$ vcspull sync` with no args passed will show a help dialog:
+
+```console
+$ vcspull sync
+Usage: vcspull sync [OPTIONS] [REPO_TERMS]...
+```
+
+### Sync all repos
+
+Depending on how your terminal works with shell escapes for expands such as the [wild card / asterisk], you may not need to quote `*`.
+
+```console
+$ vcspull sync '*'
+```
+
+[wild card / asterisk]: https://tldp.org/LDP/abs/html/special-chars.html#:~:text=wild%20card%20%5Basterisk%5D.
+
+### Filtering
+
+Filter all repos start with "django-":
+
+```console
+$ vcspull sync 'django-*'
+```
+
+### Multiple terms
+
+Filter all repos start with "django-":
+
+```console
+$ vcspull sync 'django-anymail' 'django-guardian'
+```
+
## Error handling
### Repos not found in config
diff --git a/src/vcspull/cli/sync.py b/src/vcspull/cli/sync.py
index f91328e..47b9c46 100644
--- a/src/vcspull/cli/sync.py
+++ b/src/vcspull/cli/sync.py
@@ -64,6 +64,7 @@ NO_REPOS_FOR_TERM_MSG = 'No repo found in config(s) for "{name}"'
@click.command(name="sync")
[email protected]_context
@click.argument(
"repo_terms", type=click.STRING, nargs=-1, shell_complete=get_repo_completions
)
@@ -83,7 +84,7 @@ NO_REPOS_FOR_TERM_MSG = 'No repo found in config(s) for "{name}"'
default=False,
help="Exit immediately when encountering an error syncing multiple repos",
)
-def sync(repo_terms, config, exit_on_error: bool) -> None:
+def sync(ctx, repo_terms, config, exit_on_error: bool) -> None:
if config:
configs = load_configs([config])
else:
@@ -108,7 +109,8 @@ def sync(repo_terms, config, exit_on_error: bool) -> None:
filter_repos(configs, dir=dir, vcs_url=vcs_url, name=name)
)
else:
- found_repos = configs
+ click.echo(ctx.get_help(), color=ctx.color)
+ ctx.exit()
for repo in found_repos:
try:
| vcs-python/vcspull | e4476ea38c6cb3df09de2adf8f52260cf01337e8 | diff --git a/tests/test_cli.py b/tests/test_cli.py
index 00fd9f5..4085f77 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -8,6 +8,7 @@ import yaml
from click.testing import CliRunner
from libvcs.sync.git import GitSync
+from vcspull.__about__ import __version__
from vcspull.cli import cli
from vcspull.cli.sync import EXIT_ON_ERROR_MSG, NO_REPOS_FOR_TERM_MSG
@@ -99,11 +100,96 @@ def test_sync_cli_repo_term_non_existent(
assert needle not in output
+class SyncFixture(t.NamedTuple):
+ test_id: str
+ sync_args: list[str]
+ expected_exit_code: int
+ expected_in_output: "ExpectedOutput" = None
+ expected_not_in_output: "ExpectedOutput" = None
+
+
+SYNC_REPO_FIXTURES = [
+ # Empty (root command)
+ SyncFixture(
+ test_id="empty",
+ sync_args=[],
+ expected_exit_code=0,
+ expected_in_output=["Options:", "Commands:"],
+ ),
+ # Version
+ SyncFixture(
+ test_id="--version",
+ sync_args=["--version"],
+ expected_exit_code=0,
+ expected_in_output=[__version__, ", libvcs"],
+ ),
+ SyncFixture(
+ test_id="-V",
+ sync_args=["-V"],
+ expected_exit_code=0,
+ expected_in_output=[__version__, ", libvcs"],
+ ),
+ # Help
+ SyncFixture(
+ test_id="--help",
+ sync_args=["--help"],
+ expected_exit_code=0,
+ expected_in_output=["Options:", "Commands:"],
+ ),
+ SyncFixture(
+ test_id="-h",
+ sync_args=["-h"],
+ expected_exit_code=0,
+ expected_in_output=["Options:", "Commands:"],
+ ),
+ # Sync
+ SyncFixture(
+ test_id="sync--empty",
+ sync_args=["sync"],
+ expected_exit_code=0,
+ expected_in_output="Options:",
+ expected_not_in_output="Commands:",
+ ),
+ # Sync: Help
+ SyncFixture(
+ test_id="sync---help",
+ sync_args=["sync", "--help"],
+ expected_exit_code=0,
+ expected_in_output="Options:",
+ expected_not_in_output="Commands:",
+ ),
+ SyncFixture(
+ test_id="sync--h",
+ sync_args=["sync", "-h"],
+ expected_exit_code=0,
+ expected_in_output="Options:",
+ expected_not_in_output="Commands:",
+ ),
+ # Sync: Repo terms
+ SyncFixture(
+ test_id="sync--one-repo-term",
+ sync_args=["sync", "my_git_repo"],
+ expected_exit_code=0,
+ expected_in_output="my_git_repo",
+ ),
+]
+
+
[email protected](
+ list(SyncFixture._fields),
+ SYNC_REPO_FIXTURES,
+ ids=[test.test_id for test in SYNC_REPO_FIXTURES],
+)
def test_sync(
user_path: pathlib.Path,
config_path: pathlib.Path,
tmp_path: pathlib.Path,
git_repo: GitSync,
+ test_id: str,
+ sync_args: list[str],
+ expected_exit_code: int,
+ expected_in_output: "ExpectedOutput",
+ expected_not_in_output: "ExpectedOutput",
) -> None:
runner = CliRunner()
with runner.isolated_filesystem(temp_dir=tmp_path):
@@ -124,10 +210,21 @@ def test_sync(
yaml_config.write_text(yaml_config_data, encoding="utf-8")
# CLI can sync
- result = runner.invoke(cli, ["sync", "my_git_repo"])
- assert result.exit_code == 0
+ result = runner.invoke(cli, sync_args)
+ assert result.exit_code == expected_exit_code
output = "".join(list(result.output))
- assert "my_git_repo" in output
+
+ if expected_in_output is not None:
+ if isinstance(expected_in_output, str):
+ expected_in_output = [expected_in_output]
+ for needle in expected_in_output:
+ assert needle in output
+
+ if expected_not_in_output is not None:
+ if isinstance(expected_not_in_output, str):
+ expected_not_in_output = [expected_not_in_output]
+ for needle in expected_not_in_output:
+ assert needle not in output
class SyncBrokenFixture(t.NamedTuple):
| `$ vcspull sync` should not run all repos, should print help
Related: #388, #99
No args should print help.
Syncing all should be:
```console
$ vcspull sync *
```
```console
$ vcspull sync --all
``` | 0.0 | e4476ea38c6cb3df09de2adf8f52260cf01337e8 | [
"tests/test_cli.py::test_sync[sync--empty]",
"tests/test_cli.py::test_sync[sync--one-repo-term]"
]
| [
"tests/test_cli.py::test_sync_cli_repo_term_non_existent[exists]",
"tests/test_cli.py::test_sync_cli_repo_term_non_existent[non-existent-only]",
"tests/test_cli.py::test_sync_cli_repo_term_non_existent[non-existent-mixed]",
"tests/test_cli.py::test_sync[empty]",
"tests/test_cli.py::test_sync[--version]",
"tests/test_cli.py::test_sync[-V]",
"tests/test_cli.py::test_sync[--help]",
"tests/test_cli.py::test_sync[-h]",
"tests/test_cli.py::test_sync[sync---help]",
"tests/test_cli.py::test_sync[sync--h]",
"tests/test_cli.py::test_sync_broken[normal-checkout]",
"tests/test_cli.py::test_sync_broken[normal-checkout--exit-on-error]",
"tests/test_cli.py::test_sync_broken[normal-checkout--x]",
"tests/test_cli.py::test_sync_broken[normal-first-broken]",
"tests/test_cli.py::test_sync_broken[normal-last-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--exit-on-error-first-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--x-first-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--exit-on-error-last-broken]",
"tests/test_cli.py::test_sync_broken[exit-on-error--x-last-item]"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_issue_reference",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-09-25 21:22:51+00:00 | mit | 6,197 |
|
vertica__vertica-python-372 | diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py
index 77b7184..7af4db6 100644
--- a/vertica_python/vertica/cursor.py
+++ b/vertica_python/vertica/cursor.py
@@ -519,6 +519,11 @@ class Cursor(object):
return self.format_quote(as_text(py_obj), is_copy_data)
elif isinstance(py_obj, (integer_types, float, Decimal)):
return str(py_obj)
+ elif isinstance(py_obj, tuple): # tuple and namedtuple
+ elements = [None] * len(py_obj)
+ for i in range(len(py_obj)):
+ elements[i] = self.object_to_string(py_obj[i], is_copy_data)
+ return "(" + ",".join(elements) + ")"
elif isinstance(py_obj, (datetime.datetime, datetime.date, datetime.time, UUID)):
return self.format_quote(as_text(str(py_obj)), is_copy_data)
else:
| vertica/vertica-python | 9bff1dd93e550ed70be2ae9969612ccbc495060d | diff --git a/vertica_python/tests/unit_tests/test_sql_literal.py b/vertica_python/tests/unit_tests/test_sql_literal.py
index ab51faa..b4752cd 100644
--- a/vertica_python/tests/unit_tests/test_sql_literal.py
+++ b/vertica_python/tests/unit_tests/test_sql_literal.py
@@ -14,6 +14,7 @@
from __future__ import print_function, division, absolute_import
+from collections import namedtuple
from decimal import Decimal
from uuid import UUID
import datetime
@@ -48,6 +49,14 @@ class SqlLiteralTestCase(VerticaPythonUnitTestCase):
# String
self.assertEqual(cursor.object_to_sql_literal(u"string'1"), "'string''1'")
self.assertEqual(cursor.object_to_sql_literal(b"string'1"), "'string''1'")
+ # Tuple and namedtuple
+ self.assertEqual(cursor.object_to_sql_literal(
+ (123, u"string'1", None)), "(123,'string''1',NULL)")
+ self.assertEqual(cursor.object_to_sql_literal(
+ ((1, u"a"), (2, u"b"), (3, u"c"))), "((1,'a'),(2,'b'),(3,'c'))")
+ Point = namedtuple('Point', ['x', 'y', 'z'])
+ p = Point(x=11, y=22, z=33)
+ self.assertEqual(cursor.object_to_sql_literal(p), "(11,22,33)")
def test_register_adapters(self):
class Point(object):
| Parametized queries & tuple issue
Hello!
We ran into some issues with the last release of the package.
I've seen that there were some changes for parametized queries that break some of our work.
It seems that we now can't execute queries with tuple parameters.
For instance, this dumb example
```
with conn.cursor() as curs:
curs.execute("SELECT %s in %s", (1, (1,2,3)))
for row in curs.iterate():
print(row)
```
was running successfully until `0.10.2`, but not working with `0.10.3`. We get the following issue: `TypeError: Cannot convert <class 'tuple'> type object to an SQL string`
Sorry if this is an expected behavior of the last release :)
Have a nice day! | 0.0 | 9bff1dd93e550ed70be2ae9969612ccbc495060d | [
"vertica_python/tests/unit_tests/test_sql_literal.py::SqlLiteralTestCase::test_default_adapters"
]
| [
"vertica_python/tests/unit_tests/test_sql_literal.py::SqlLiteralTestCase::test_register_adapters"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2020-05-07 06:48:40+00:00 | apache-2.0 | 6,198 |
|
victorskl__yawsso-94 | diff --git a/yawsso/cli.py b/yawsso/cli.py
index 4b2195e..db41fad 100644
--- a/yawsso/cli.py
+++ b/yawsso/cli.py
@@ -36,6 +36,9 @@ def boot():
if args.bin:
core.aws_bin = args.bin
+ if args.region:
+ core.region_flag = args.region
+
logger.log(TRACE, f"args: {args}")
logger.log(TRACE, f"AWS_CONFIG_FILE: {core.aws_config_file}")
logger.log(TRACE, f"AWS_SHARED_CREDENTIALS_FILE: {core.aws_shared_credentials_file}")
@@ -60,6 +63,7 @@ def parser():
ap.add_argument("-t", "--trace", help="Trace output", action="store_true")
ap.add_argument("-e", "--export-vars", dest="export_vars1", help="Print out AWS ENV vars", action="store_true")
ap.add_argument("-v", "--version", help="Print version and exit", action="store_true")
+ ap.add_argument("-r", "--region", help="Add region to credentials file", action="store_true")
sp = ap.add_subparsers(title="available commands", metavar="", dest="command")
diff --git a/yawsso/core.py b/yawsso/core.py
index e9ca448..d80c39f 100644
--- a/yawsso/core.py
+++ b/yawsso/core.py
@@ -11,7 +11,8 @@ profiles = None
aws_sso_cache_path = u.xu(os.getenv("AWS_SSO_CACHE_PATH", Constant.AWS_SSO_CACHE_PATH.value))
aws_config_file = u.xu(os.getenv("AWS_CONFIG_FILE", Constant.AWS_CONFIG_FILE.value))
aws_shared_credentials_file = u.xu(os.getenv("AWS_SHARED_CREDENTIALS_FILE", Constant.AWS_SHARED_CREDENTIALS_FILE.value))
-aws_default_region = os.getenv("AWS_DEFAULT_REGION", Constant.AWS_DEFAULT_REGION.value)
+aws_default_region = os.getenv("AWS_DEFAULT_REGION")
+region_flag = False # See https://github.com/victorskl/yawsso/issues/76
def get_aws_cli_v2_sso_cached_login(profile):
@@ -34,19 +35,29 @@ def update_aws_cli_v1_credentials(profile_name, profile, credentials):
logger.warning(f"No appropriate credentials found. Skip syncing profile `{profile_name}`")
return
- # region = profile.get("region", aws_default_region)
config = u.read_config(aws_shared_credentials_file)
+
if config.has_section(profile_name):
config.remove_section(profile_name)
+
config.add_section(profile_name)
- # config.set(profile_name, "region", region) # See https://github.com/victorskl/yawsso/issues/76
config.set(profile_name, "aws_access_key_id", credentials["accessKeyId"])
config.set(profile_name, "aws_secret_access_key", credentials["secretAccessKey"])
config.set(profile_name, "aws_session_token", credentials["sessionToken"])
config.set(profile_name, "aws_security_token", credentials["sessionToken"])
+
+ # set expiration
ts_expires_millisecond = credentials["expiration"]
dt_utc = str(datetime.utcfromtimestamp(ts_expires_millisecond / 1000.0).isoformat() + '+0000')
config.set(profile_name, "aws_session_expiration", dt_utc)
+
+ # set region
+ region = profile.get("region", aws_default_region)
+ if region_flag and region:
+ # See https://github.com/victorskl/yawsso/issues/88
+ config.set(profile_name, "region", region)
+
+ # write the config out
u.write_config(aws_shared_credentials_file, config)
logger.debug(f"Done syncing AWS CLI v1 credentials using AWS CLI v2 SSO login session for profile `{profile_name}`")
| victorskl/yawsso | 5a838dbe02044007d333a716ae0801a9c9c09954 | diff --git a/tests/test_cli.py b/tests/test_cli.py
index 58ad488..e246da3 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1056,3 +1056,16 @@ class CLIUnitTests(TestCase):
self.assertNotEqual(new_tok, 'tok')
self.assertEqual(new_tok, 'VeryLongBase664String==')
verify(cli.utils, times=1).Poll(...)
+
+ def test_region_flag(self):
+ """
+ python -m unittest tests.test_cli.CLIUnitTests.test_region_flag
+ """
+ with ArgvContext(program, '-p', 'dev', '-t', '-r'):
+ cli.main()
+ cred = cli.utils.read_config(self.credentials.name)
+ new_tok = cred['dev']['aws_session_token']
+ self.assertNotEqual(new_tok, 'tok')
+ self.assertEqual(new_tok, 'VeryLongBase664String==')
+ self.assertEqual(cred['dev']['region'], 'ap-southeast-2')
+ verify(cli.utils, times=2).invoke(...)
| Add parameter to control setting the region in the .aws/credentials file
Hi @victorskl,
I came across the issue reported in https://github.com/victorskl/yawsso/issues/76 because I was wondering why the aws clients are telling me that there is no default region defined in the profile. It has been working before, but then since I updated yawsso I started to have an issue. So actually my request would be the opposite as what is explained in https://github.com/victorskl/yawsso/issues/76. Do you think it would be possible to implement a parameter so that you can define whether you want the region in the credentials file or not? Something like a switch "-r" to tell it to copy the region for example?
yawsso -p dev:foo -r | 0.0 | 5a838dbe02044007d333a716ae0801a9c9c09954 | [
"["
]
| [
"tests/test_cli.py::CLIUnitTests::test_invalid_bin",
"tests/test_cli.py::CLIUnitTests::test_invoke_cmd_fail",
"tests/test_cli.py::CLIUnitTests::test_fetch_credentials_with_assume_role_no_success",
"tests/test_cli.py::CLIUnitTests::test_no_such_profile_section",
"tests/test_cli.py::CLIUnitTests::test_poll_cmd_fail",
"tests/test_cli.py::CLIUnitTests::test_unknown_command",
"tests/test_cli.py::CLIUnitTests::test_credential_not_found_2",
"tests/test_cli.py::CLIUnitTests::test_load_json_value_error",
"tests/test_cli.py::CLIUnitTests::test_sso_cache_not_found",
"tests/test_cli.py::CLIUnitTests::test_aws_cli_version_fail",
"tests/test_cli.py::CLIUnitTests::test_poll_cmd_success",
"tests/test_cli.py::CLIUnitTests::test_config_not_found",
"tests/test_cli.py::CLIUnitTests::test_append_cli_global_options",
"tests/test_cli.py::CLIUnitTests::test_version_flag",
"tests/test_cli.py::CLIUnitTests::test_get_role_max_session_duration_no_success",
"tests/test_cli.py::CLIUnitTests::test_aws_cli_v1",
"tests/test_cli.py::CLIUnitTests::test_eager_sync_source_profile_should_skip",
"tests/test_cli.py::CLIUnitTests::test_xu",
"tests/test_cli.py::CLIUnitTests::test_sso_get_role_credentials_fail",
"tests/test_cli.py::CLIUnitTests::test_parse_credentials_file_session_expiry"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2024-03-03 11:38:33+00:00 | mit | 6,199 |
|
vinitkumar__json2xml-119 | diff --git a/examples/booleanjson.json b/examples/booleanjson.json
new file mode 100644
index 0000000..a784c7b
--- /dev/null
+++ b/examples/booleanjson.json
@@ -0,0 +1,8 @@
+{
+ "boolean": true,
+ "boolean_dict_list": [
+ {"boolean_dict": {"boolean": true}},
+ {"boolean_dict": {"boolean": false}}
+ ],
+ "boolean_list": [true, false]
+}
diff --git a/json2xml/dicttoxml.py b/json2xml/dicttoxml.py
index d5e3f9f..489d55f 100755
--- a/json2xml/dicttoxml.py
+++ b/json2xml/dicttoxml.py
@@ -139,6 +139,13 @@ def convert(obj, ids, attr_type, item_func, cdata, item_wrap, parent="root"):
item_name = item_func(parent)
+ # since bool is also a subtype of number.Number and int, the check for bool
+ # never comes and hence we get wrong value for the xml type bool
+ # here, we just change order and check for bool first, because no other
+ # type other than bool can be true for bool check
+ if isinstance(obj, bool):
+ return convert_bool(item_name, obj, attr_type, cdata)
+
if isinstance(obj, (numbers.Number, str)):
return convert_kv(
key=item_name, val=obj, attr_type=attr_type, attr={}, cdata=cdata
@@ -153,9 +160,6 @@ def convert(obj, ids, attr_type, item_func, cdata, item_wrap, parent="root"):
cdata=cdata,
)
- if isinstance(obj, bool):
- return convert_bool(item_name, obj, attr_type, cdata)
-
if obj is None:
return convert_none(item_name, "", attr_type, cdata)
@@ -185,7 +189,14 @@ def convert_dict(obj, ids, parent, attr_type, item_func, cdata, item_wrap):
key, attr = make_valid_xml_name(key, attr)
- if isinstance(val, (numbers.Number, str)):
+ # since bool is also a subtype of number.Number and int, the check for bool
+ # never comes and hence we get wrong value for the xml type bool
+ # here, we just change order and check for bool first, because no other
+ # type other than bool can be true for bool check
+ if isinstance(val, bool):
+ addline(convert_bool(key, val, attr_type, attr, cdata))
+
+ elif isinstance(val, (numbers.Number, str)):
addline(
convert_kv(
key=key, val=val, attr_type=attr_type, attr=attr, cdata=cdata
@@ -203,9 +214,6 @@ def convert_dict(obj, ids, parent, attr_type, item_func, cdata, item_wrap):
)
)
- elif isinstance(val, bool):
- addline(convert_bool(key, val, attr_type, attr, cdata))
-
elif isinstance(val, dict):
if attr_type:
attr["type"] = get_xml_type(val)
| vinitkumar/json2xml | 4b2007ce4cc9998fbbecd0372ae33fdac4dd4195 | diff --git a/tests/test_json2xml.py b/tests/test_json2xml.py
index bbf7ae4..872ee32 100644
--- a/tests/test_json2xml.py
+++ b/tests/test_json2xml.py
@@ -176,3 +176,11 @@ class TestJson2xml(unittest.TestCase):
with pytest.raises(InvalidDataError) as pytest_wrapped_e:
json2xml.Json2xml(decoded).to_xml()
assert pytest_wrapped_e.type == InvalidDataError
+
+ def test_read_boolean_data_from_json(self):
+ """Test correct return for boolean types."""
+ data = readfromjson("examples/booleanjson.json")
+ result = json2xml.Json2xml(data).to_xml()
+ dict_from_xml = xmltodict.parse(result)
+ assert dict_from_xml["all"]["boolean"]["#text"] != 'True'
+ assert dict_from_xml["all"]["boolean"]["#text"] == 'true'
| Boolean types are not converted to their XML equivalents.
**Describe the bug**
When converting a JSON object with boolean type values, `Json2xml` is not converting the values to their XML equivalents. `Json2xml` should be exporting the values in the XML as the lowercase words `true` and `false` respectively. Instead, `Json2xml` is exporting them as Python boolean types using the capitalized words `True` and `False`.
**To Reproduce**
Steps to reproduce the behavior:
1. Given the following JSON object:
```json
{
"boolean": true,
"boolean_dict_list": [
{"boolean_dict": {"boolean": true}},
{"boolean_dict": {"boolean": false}}
],
"boolean_list": [true, false]
}
```
2. Calling the `Json2xml` conversion like so:
```python
xml = json2xml.Json2xml(sample_json, pretty=True).to_xml()
```
3. Produces the following XML:
```xml
<all>
<boolean type="bool">True</boolean>
<boolean_dict_list type="list">
<item type="dict">
<boolean_dict type="dict">
<boolean type="bool">True</boolean>
</boolean_dict>
</item>
<item type="dict">
<boolean_dict type="dict">
<boolean type="bool">False</boolean>
</boolean_dict>
</item>
</boolean_dict_list>
<item type="bool">True</item>
<item type="bool">False</item>
</all>
```
Notice all the boolean values are capitalized instead of being lowercase like they should be in XML and JSON. There also seems to be a problem with the `boolean_list` array, it is missing its parent tag.
**Expected behavior**
`Json2xml` should produce an XML string that looks like this:
```xml
<all>
<boolean type="bool">true</boolean>
<boolean_dict_list type="list">
<item type="dict">
<boolean_dict type="dict">
<boolean type="bool">true</boolean>
</boolean_dict>
</item>
<item type="dict">
<boolean_dict type="dict">
<boolean type="bool">false</boolean>
</boolean_dict>
</item>
</boolean_dict_list>
<boolean_list type="list">
<item type="bool">true</item>
<item type="bool">false</item>
</boolean_list>
</all>
```
**Additional context**
The problem with the capitalized boolean values is because of the following statements in the `json2xml.dicttoxml` module:
```python
def convert(obj, ids, attr_type, item_func, cdata, item_wrap, parent="root"):
"""Routes the elements of an object to the right function to convert them
based on their data type"""
LOG.info(f'Inside convert(). obj type is: "{type(obj).__name__}", obj="{str(obj)}"')
item_name = item_func(parent)
# Booleans are converted using this function because a Python boolean is a subclass of Number
if isinstance(obj, (numbers.Number, str)):
return convert_kv(
key=item_name, val=obj, attr_type=attr_type, attr={}, cdata=cdata
)
if hasattr(obj, "isoformat"):
return convert_kv(
key=item_name,
val=obj.isoformat(),
attr_type=attr_type,
attr={},
cdata=cdata,
)
# This is never evaluated because Python booleans are subclasses of Python integers
if isinstance(obj, bool):
return convert_bool(item_name, obj, attr_type, cdata)
```
Python booleans are subclasses of integers, so the boolean values are passed to `convert_kv` instead of `convert_bool` because an integer is also a `numbers.Number`. The following statements evaluate to `True` in Python:
```python
# Booleans are integers
isinstance(True, int)
# Booleans are numbers
isinstance(True, numbers.Number)
# Booleans are booleans
isinstance(True, bool)
``` | 0.0 | 4b2007ce4cc9998fbbecd0372ae33fdac4dd4195 | [
"tests/test_json2xml.py::TestJson2xml::test_read_boolean_data_from_json"
]
| [
"tests/test_json2xml.py::TestJson2xml::test_attrs",
"tests/test_json2xml.py::TestJson2xml::test_bad_data",
"tests/test_json2xml.py::TestJson2xml::test_custom_wrapper_and_indent",
"tests/test_json2xml.py::TestJson2xml::test_dict2xml_no_root",
"tests/test_json2xml.py::TestJson2xml::test_dict2xml_with_custom_root",
"tests/test_json2xml.py::TestJson2xml::test_dict2xml_with_root",
"tests/test_json2xml.py::TestJson2xml::test_dicttoxml_bug",
"tests/test_json2xml.py::TestJson2xml::test_empty_array",
"tests/test_json2xml.py::TestJson2xml::test_item_wrap",
"tests/test_json2xml.py::TestJson2xml::test_json_to_xml_conversion",
"tests/test_json2xml.py::TestJson2xml::test_no_item_wrap",
"tests/test_json2xml.py::TestJson2xml::test_no_wrapper",
"tests/test_json2xml.py::TestJson2xml::test_read_from_invalid_json",
"tests/test_json2xml.py::TestJson2xml::test_read_from_invalid_jsonstring",
"tests/test_json2xml.py::TestJson2xml::test_read_from_json",
"tests/test_json2xml.py::TestJson2xml::test_read_from_jsonstring",
"tests/test_json2xml.py::TestJson2xml::test_read_from_url",
"tests/test_json2xml.py::TestJson2xml::test_read_from_wrong_url"
]
| {
"failed_lite_validators": [
"has_added_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-04-18 08:43:56+00:00 | apache-2.0 | 6,200 |
|
vitalik__django-ninja-133 | diff --git a/docs/src/tutorial/query/code010.py b/docs/src/tutorial/query/code010.py
index b60e90d..7150396 100644
--- a/docs/src/tutorial/query/code010.py
+++ b/docs/src/tutorial/query/code010.py
@@ -1,11 +1,16 @@
import datetime
-from ninja import Schema, Query
+from typing import List
+
+from pydantic import Field
+
+from ninja import Query, Schema
class Filters(Schema):
limit: int = 100
offset: int = None
query: str = None
+ category__in: List[str] = Field(None, alias="categories")
@api.get("/filter")
diff --git a/ninja/signature/details.py b/ninja/signature/details.py
index cca9b2a..488aa30 100644
--- a/ninja/signature/details.py
+++ b/ninja/signature/details.py
@@ -1,9 +1,20 @@
import inspect
from collections import defaultdict, namedtuple
-from typing import Any, Callable, Dict, List
+from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional
+
+try:
+ from typing import get_origin # type: ignore
+except ImportError: # pragma: no coverage
+
+ def get_origin(tp: Any) -> Optional[Any]:
+ return getattr(tp, "__origin__", None)
+
import pydantic
+if TYPE_CHECKING:
+ from pydantic.fields import ModelField # pragma: no cover
+
from ninja import params
from ninja.signature.utils import get_path_param_names, get_typed_signature
@@ -117,10 +128,19 @@ def is_pydantic_model(cls: Any) -> bool:
def is_collection_type(annotation: Any) -> bool:
# List[int] => __origin__ = list, __args__ = int
- origin = getattr(annotation, "__origin__", None)
+ origin = get_origin(annotation)
return origin in (List, list, set, tuple) # TODO: I gues we should handle only list
+def detect_pydantic_model_collection_fields(model: pydantic.BaseModel) -> List[str]:
+ def _list_field_name(field: "ModelField") -> Optional[str]:
+ if get_origin(field.outer_type_) in (List, list, tuple, set):
+ return str(field.alias)
+ return None
+
+ return list(filter(None, map(_list_field_name, model.__fields__.values())))
+
+
def detect_collection_fields(args: List[FuncParam]) -> List[str]:
"""
QueryDict has values that are always lists, so we need to help django ninja to understand
@@ -130,11 +150,6 @@ def detect_collection_fields(args: List[FuncParam]) -> List[str]:
result = [i.name for i in args if i.is_collection]
if len(args) == 1 and is_pydantic_model(args[0].annotation):
- # There is a special case - when query param of form param is only one and it's defined as pydantic model
- # In that case we need to detect collection
- # see #34 for more details about the issue
- for name, annotation in args[0].annotation.__annotations__.items():
- if is_collection_type(annotation):
- result.append(name)
+ result += detect_pydantic_model_collection_fields(args[0].annotation)
return result
| vitalik/django-ninja | b9c65dad17e9f67bad6440eae829da79b4efe667 | diff --git a/tests/test_docs/test_query.py b/tests/test_docs/test_query.py
index a7d055d..720ea95 100644
--- a/tests/test_docs/test_query.py
+++ b/tests/test_docs/test_query.py
@@ -63,16 +63,39 @@ def test_examples():
# Schema
assert client.get("/filter").json() == {
- "filters": {"limit": 100, "offset": None, "query": None}
+ "filters": {
+ "limit": 100,
+ "offset": None,
+ "query": None,
+ "category__in": None,
+ }
}
assert client.get("/filter?limit=10").json() == {
- "filters": {"limit": 10, "offset": None, "query": None}
+ "filters": {
+ "limit": 10,
+ "offset": None,
+ "query": None,
+ "category__in": None,
+ }
}
assert client.get("/filter?offset=10").json() == {
- "filters": {"limit": 100, "offset": 10, "query": None}
+ "filters": {"limit": 100, "offset": 10, "query": None, "category__in": None}
}
assert client.get("/filter?query=10").json() == {
- "filters": {"limit": 100, "offset": None, "query": "10"}
+ "filters": {
+ "limit": 100,
+ "offset": None,
+ "query": "10",
+ "category__in": None,
+ }
+ }
+ assert client.get("/filter?categories=a&categories=b").json() == {
+ "filters": {
+ "limit": 100,
+ "offset": None,
+ "query": None,
+ "category__in": ["a", "b"],
+ }
}
schema = api.get_openapi_schema("")
@@ -96,4 +119,14 @@ def test_examples():
"required": False,
"schema": {"title": "Query", "type": "string"},
},
+ {
+ "in": "query",
+ "name": "categories",
+ "required": False,
+ "schema": {
+ "title": "Categories",
+ "type": "array",
+ "items": {"type": "string"},
+ },
+ },
]
diff --git a/tests/test_lists.py b/tests/test_lists.py
index 71338cb..66b0ba9 100644
--- a/tests/test_lists.py
+++ b/tests/test_lists.py
@@ -1,7 +1,7 @@
import pytest
from typing import List
from ninja import Router, Query, Form, Schema
-from pydantic import BaseModel
+from pydantic import BaseModel, Field
from client import NinjaClient
@@ -12,7 +12,9 @@ router = Router()
@router.post("/list1")
def listview1(
- request, query: List[int] = Query(...), form: List[int] = Form(...),
+ request,
+ query: List[int] = Query(...),
+ form: List[int] = Form(...),
):
return {
"query": query,
@@ -22,7 +24,9 @@ def listview1(
@router.post("/list2")
def listview2(
- request, body: List[int], query: List[int] = Query(...),
+ request,
+ body: List[int],
+ query: List[int] = Query(...),
):
return {
"query": query,
@@ -52,11 +56,13 @@ def listviewdefault(request, body: List[int] = [1]):
class Filters(Schema):
tags: List[str] = []
+ other_tags: List[str] = Field([], alias="other_tags_alias")
@router.post("/list4")
def listview4(
- request, filters: Filters = Query(...),
+ request,
+ filters: Filters = Query(...),
):
return {
"filters": filters,
@@ -96,19 +102,19 @@ client = NinjaClient(router)
{"body": [1, 2]},
),
(
- "/list4?tags=a&tags=b",
+ "/list4?tags=a&tags=b&other_tags_alias=a&other_tags_alias=b",
{},
- {"filters": {"tags": ["a", "b"]}},
+ {"filters": {"tags": ["a", "b"], "other_tags": ["a", "b"]}},
),
(
- "/list4?tags=abc",
+ "/list4?tags=abc&other_tags_alias=abc",
{},
- {"filters": {"tags": ["abc"]}},
+ {"filters": {"tags": ["abc"], "other_tags": ["abc"]}},
),
(
"/list4",
{},
- {"filters": {"tags": []}},
+ {"filters": {"tags": [], "other_tags": []}},
),
]
# fmt: on
| Query parameters from Schema do not recognise lists with pydantic.Field alias
Using a schema to encapsulate GET requests with a `pydantic.Field` to handle `alias` will result in a 422 error.
```python
class Filters(Schema):
slug__in: typing.List[str] = pydantic.Field(
None,
alias="slugs",
)
@api.get("/filters/")
def test_filters(request, filters: Filters = Query(...)):
return filters.dict()
```
Expected response to http://127.0.0.1:8000/api/filters/?slugs=a&slugs=b
```python
{
"slug__in": [
"a",
"b"
]
}
```
Actual response to http://127.0.0.1:8000/api/filters/?slugs=a&slugs=b
```python
{
"detail": [
{
"loc": [
"query",
"filters",
"slugs"
],
"msg": "value is not a valid list",
"type": "type_error.list"
}
]
}
```
One work around is to *not* use aliases at all, but this is not ideal.
```python
class Filters(Schema):
slugs: typing.List[str] = pydantic.Field(None)
```
| 0.0 | b9c65dad17e9f67bad6440eae829da79b4efe667 | [
"tests/test_docs/test_query.py::test_examples",
"tests/test_lists.py::test_list[/list4?tags=a&tags=b&other_tags_alias=a&other_tags_alias=b-kwargs5-expected_response5]",
"tests/test_lists.py::test_list[/list4?tags=abc&other_tags_alias=abc-kwargs6-expected_response6]"
]
| [
"tests/test_lists.py::test_list[/list1?query=1&query=2-kwargs0-expected_response0]",
"tests/test_lists.py::test_list[/list2?query=1&query=2-kwargs1-expected_response1]",
"tests/test_lists.py::test_list[/list3-kwargs2-expected_response2]",
"tests/test_lists.py::test_list[/list-default-kwargs3-expected_response3]",
"tests/test_lists.py::test_list[/list-default-kwargs4-expected_response4]",
"tests/test_lists.py::test_list[/list4-kwargs7-expected_response7]"
]
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-05-07 14:52:51+00:00 | mit | 6,201 |
|
vitalik__django-ninja-184 | diff --git a/docs/docs/tutorial/response-schema.md b/docs/docs/tutorial/response-schema.md
index f31ce32..7f1359b 100644
--- a/docs/docs/tutorial/response-schema.md
+++ b/docs/docs/tutorial/response-schema.md
@@ -286,3 +286,21 @@ Organization.update_forward_refs() # !!! this is important
def list_organizations(request):
...
```
+
+## Self-referencing schemes from `create_schema()`
+
+To be able to use the method `update_forward_refs()` from a schema generated via `create_schema()`,
+the "name" of the class needs to be in our namespace. In this case it is very important to pass
+the `name` parameter to `create_schema()`
+
+```Python hl_lines="3"
+UserSchema = create_schema(
+ User,
+ name='UserSchema', # !!! this is important for update_forward_refs()
+ fields=['id', 'username']
+ custom_fields=[
+ ('manager', 'UserSchema', None),
+ ]
+)
+UserSchema.update_forward_refs()
+```
diff --git a/ninja/operation.py b/ninja/operation.py
index 1956a61..f9718af 100644
--- a/ninja/operation.py
+++ b/ninja/operation.py
@@ -94,6 +94,10 @@ class Operation:
result = self.view_func(request, **values)
return self._result_to_response(request, result)
except Exception as e:
+ if isinstance(e, TypeError) and "required positional argument" in str(e):
+ msg = "Did you fail to use functools.wraps() in a decorator?"
+ msg = f"{e.args[0]}: {msg}" if e.args else msg
+ e.args = (msg,) + e.args[1:]
return self.api.on_exception(request, e)
def set_api_instance(self, api: "NinjaAPI", router: "Router") -> None:
| vitalik/django-ninja | efb29207ca764d34146cb59cfcb98f4cb3ebb94d | diff --git a/tests/test_app.py b/tests/test_app.py
index 5a2e4a5..307f0c5 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -63,11 +63,14 @@ def html(request):
def file_response(request):
tmp = NamedTemporaryFile(delete=False)
try:
- with open(tmp.name, 'wb') as f:
- f.write(b'this is a file')
- return FileResponse(open(tmp.name, 'rb'))
+ with open(tmp.name, "wb") as f:
+ f.write(b"this is a file")
+ return FileResponse(open(tmp.name, "rb"))
finally:
- os.remove(tmp.name)
+ try:
+ os.remove(tmp.name)
+ except PermissionError:
+ pass
@pytest.mark.parametrize(
@@ -109,4 +112,3 @@ def test_validates():
urls = api2.urls
finally:
os.environ["NINJA_SKIP_REGISTRY"] = "yes"
-
diff --git a/tests/test_wraps.py b/tests/test_wraps.py
new file mode 100644
index 0000000..b5800ed
--- /dev/null
+++ b/tests/test_wraps.py
@@ -0,0 +1,103 @@
+from functools import wraps
+import pytest
+from ninja import Router
+from ninja.testing import TestClient
+
+
+router = Router()
+client = TestClient(router)
+
+
+def a_good_test_wrapper(f):
+ """Validate that decorators using functools.wraps(), work as expected"""
+
+ @wraps(f)
+ def wrapper(*args, **kwargs):
+ return f(*args, **kwargs)
+
+ return wrapper
+
+
+def a_bad_test_wrapper(f):
+ """Validate that decorators failing to using functools.wraps(), fail"""
+
+ def wrapper(*args, **kwargs):
+ return f(*args, **kwargs)
+
+ return wrapper
+
+
[email protected]("/text")
+@a_good_test_wrapper
+def get_text(
+ request,
+):
+ return "Hello World"
+
+
[email protected]("/path/{item_id}")
+@a_good_test_wrapper
+def get_id(request, item_id):
+ return item_id
+
+
[email protected]("/query")
+@a_good_test_wrapper
+def get_query_type(request, query: int):
+ return f"foo bar {query}"
+
+
[email protected]("/path-query/{item_id}")
+@a_good_test_wrapper
+def get_id(request, item_id, query: int):
+ return f"foo bar {item_id} {query}"
+
+
[email protected]("/text-bad")
+@a_bad_test_wrapper
+def get_text(
+ request,
+):
+ return "Hello World"
+
+
[email protected]("/path-bad/{item_id}")
+@a_bad_test_wrapper
+def get_id(request, item_id):
+ return item_id
+
+
[email protected]("/query-bad")
+@a_bad_test_wrapper
+def get_query_type(request, query: int):
+ return f"foo bar {query}"
+
+
[email protected]("/path-query-bad/{item_id}")
+@a_bad_test_wrapper
+def get_id_bad(request, item_id, query: int):
+ return f"foo bar {item_id} {query}"
+
+
[email protected](
+ "path,expected_status,expected_response",
+ [
+ ("/text", 200, "Hello World"),
+ ("/path/id", 200, "id"),
+ ("/query?query=1", 200, "foo bar 1"),
+ ("/path-query/id?query=2", 200, "foo bar id 2"),
+ ("/text-bad", 200, "Hello World"), # no params so passes
+ ("/path-bad/id", None, TypeError),
+ ("/query-bad?query=1", None, TypeError),
+ ("/path-query-bad/id?query=2", None, TypeError),
+ ],
+)
+def test_get_path(path, expected_status, expected_response):
+ if isinstance(expected_response, str):
+ response = client.get(path)
+ assert response.status_code == expected_status
+ assert response.json() == expected_response
+ else:
+ match = r"Did you fail to use functools.wraps\(\) in a decorator\?"
+ with pytest.raises(expected_response, match=match):
+ client.get(path)
| Decorators
```
@api.get("/add")
@cache_page(60 * 15)
def add(request, a: int, b: int):
return {"result": a + b}
```
so currently this will not work due to inspection procedure...
I guess there must be some `@decorate` helper to allow to add custom decorators that will not conflict with arguments/annotations resolution
UPD:
looks like when `functools.wraps` is used it is possible to get to the original function declaration via `__wrapped__` attribute
| 0.0 | efb29207ca764d34146cb59cfcb98f4cb3ebb94d | [
"tests/test_wraps.py::test_get_path[/path-bad/id-None-TypeError]",
"tests/test_wraps.py::test_get_path[/query-bad?query=1-None-TypeError]",
"tests/test_wraps.py::test_get_path[/path-query-bad/id?query=2-None-TypeError]"
]
| [
"tests/test_app.py::test_method[get-/-200-/-False]",
"tests/test_app.py::test_method[get-/get-200-this",
"tests/test_app.py::test_method[post-/post-200-this",
"tests/test_app.py::test_method[put-/put-200-this",
"tests/test_app.py::test_method[patch-/patch-200-this",
"tests/test_app.py::test_method[delete-/delete-200-this",
"tests/test_app.py::test_method[get-/multi-200-this",
"tests/test_app.py::test_method[post-/multi-200-this",
"tests/test_app.py::test_method[patch-/multi-405-Method",
"tests/test_app.py::test_method[get-/html-200-html-False]",
"tests/test_app.py::test_method[get-/file-200-this",
"tests/test_app.py::test_validates",
"tests/test_wraps.py::test_get_path[/text-200-Hello",
"tests/test_wraps.py::test_get_path[/path/id-200-id]",
"tests/test_wraps.py::test_get_path[/query?query=1-200-foo",
"tests/test_wraps.py::test_get_path[/path-query/id?query=2-200-foo",
"tests/test_wraps.py::test_get_path[/text-bad-200-Hello"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false
} | 2021-07-27 17:00:09+00:00 | mit | 6,202 |
|
vitalik__django-ninja-185 | diff --git a/ninja/params_models.py b/ninja/params_models.py
index e8f8c7c..2ddabe6 100644
--- a/ninja/params_models.py
+++ b/ninja/params_models.py
@@ -48,6 +48,15 @@ class ParamModel(BaseModel, ABC):
varname = getattr(cls, "_single_attr", None)
if varname:
data = {varname: data}
+
+ mixed_attrs = getattr(cls, "_mixed_attrs", None)
+ if mixed_attrs:
+ for param_name, varname in mixed_attrs.items():
+ if varname not in data:
+ data[varname] = {}
+ if param_name in data:
+ data[varname][param_name] = data.pop(param_name)
+
# TODO: I guess if data is not dict - raise an HttpBadRequest
return cls(**data)
diff --git a/ninja/signature/details.py b/ninja/signature/details.py
index 6659a76..5e0d51f 100644
--- a/ninja/signature/details.py
+++ b/ninja/signature/details.py
@@ -34,9 +34,9 @@ class ViewSignature:
self.params = []
for name, arg in self.signature.parameters.items():
if name == "request":
- # TODO: maybe better assert that 1st param is request or check by type?
- # maybe even have attribute like `has_request`
- # so that users can ignroe passing request if not needed
+ # TODO: maybe better assert that 1st param is request or check by type?
+ # maybe even have attribute like `has_request`
+ # so that users can ignore passing request if not needed
continue
if arg.kind == arg.VAR_KEYWORD:
@@ -69,6 +69,23 @@ class ViewSignature:
if cls._in() == "body" or is_pydantic_model(args[0].annotation):
attrs["_single_attr"] = args[0].name
+ elif cls._in() == "query":
+ pydantic_models = [
+ arg for arg in args if is_pydantic_model(arg.annotation)
+ ]
+ if pydantic_models:
+ mixed_attrs = {}
+ for modeled_attr in pydantic_models:
+ for (
+ attr_name,
+ field,
+ ) in modeled_attr.annotation.__fields__.items():
+ mixed_attrs[attr_name] = modeled_attr.name
+ if hasattr(field, "alias"):
+ mixed_attrs[field.alias] = modeled_attr.name
+
+ attrs["_mixed_attrs"] = mixed_attrs
+
# adding annotations:
attrs["__annotations__"] = {i.name: i.annotation for i in args}
| vitalik/django-ninja | d1212693462a8753f187fecfd8b6686b35647ed6 | diff --git a/tests/test_query_schema.py b/tests/test_query_schema.py
index db37f0c..fca70c0 100644
--- a/tests/test_query_schema.py
+++ b/tests/test_query_schema.py
@@ -1,6 +1,7 @@
from datetime import datetime
from enum import IntEnum
+import pytest
from pydantic import Field
from ninja import NinjaAPI, Query, Schema, files
@@ -20,6 +21,11 @@ class Filter(Schema):
range: Range = Range.TWENTY
+class Data(Schema):
+ an_int: int = Field(alias="int", default=0)
+ a_float: float = Field(alias="float", default=1.5)
+
+
api = NinjaAPI()
@@ -28,6 +34,17 @@ def query_params_schema(request, filters: Filter = Query(...)):
return filters.dict()
[email protected]("/test-mixed")
+def query_params_mixed_schema(
+ request,
+ query1: int,
+ query2: int = 5,
+ filters: Filter = Query(...),
+ data: Data = Query(...),
+):
+ return dict(query1=query1, query2=query2, filters=filters.dict(), data=data.dict())
+
+
def test_request():
client = TestClient(api)
response = client.get("/test?from=1&to=2&range=20&foo=1&range2=50")
@@ -42,6 +59,42 @@ def test_request():
assert response.status_code == 422
+def test_request_mixed():
+ client = TestClient(api)
+ response = client.get(
+ "/test-mixed?from=1&to=2&range=20&foo=1&range2=50&query1=2&int=3&float=1.6"
+ )
+ print(response.json())
+ assert response.json() == {
+ "data": {"a_float": 1.6, "an_int": 3},
+ "filters": {
+ "from_datetime": "1970-01-01T00:00:01Z",
+ "range": 20,
+ "to_datetime": "1970-01-01T00:00:02Z",
+ },
+ "query1": 2,
+ "query2": 5,
+ }
+
+ response = client.get(
+ "/test-mixed?from=1&to=2&range=20&foo=1&range2=50&query1=2&query2=10"
+ )
+ print(response.json())
+ assert response.json() == {
+ "data": {"a_float": 1.5, "an_int": 0},
+ "filters": {
+ "from_datetime": "1970-01-01T00:00:01Z",
+ "range": 20,
+ "to_datetime": "1970-01-01T00:00:02Z",
+ },
+ "query1": 2,
+ "query2": 10,
+ }
+
+ response = client.get("/test-mixed?from=1&to=2")
+ assert response.status_code == 422
+
+
def test_schema():
schema = api.get_openapi_schema()
params = schema["paths"]["/api/test"]["get"]["parameters"]
| mixing query param bug
<img width="1089" alt="CleanShot 2021-07-21 at 15 23 44@2x" src="https://user-images.githubusercontent.com/95222/126487840-33ec0cf2-5978-4a1f-816e-73afe970561b.png">
this works
but this
<img width="1157" alt="CleanShot 2021-07-21 at 15 24 51@2x" src="https://user-images.githubusercontent.com/95222/126488014-853ee9bf-9574-49a4-b5a3-b11cc3ac9606.png">
not:
<img width="718" alt="CleanShot 2021-07-21 at 15 24 17@2x" src="https://user-images.githubusercontent.com/95222/126487860-88b282ff-2914-4d3d-8bb9-e1fa8552e178.png">
| 0.0 | d1212693462a8753f187fecfd8b6686b35647ed6 | [
"tests/test_query_schema.py::test_request_mixed"
]
| [
"tests/test_query_schema.py::test_request",
"tests/test_query_schema.py::test_schema"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks",
"has_media",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2021-07-28 00:21:42+00:00 | mit | 6,203 |
|
vitalik__django-ninja-187 | diff --git a/ninja/main.py b/ninja/main.py
index e4fbf7d..3ccf3c6 100644
--- a/ninja/main.py
+++ b/ninja/main.py
@@ -313,12 +313,13 @@ class NinjaAPI:
def urls(self) -> Tuple[Any, ...]:
self._validate()
return (
- self._get_urls(),
+ self._get_urls,
"ninja",
self.urls_namespace.split(":")[-1],
# ^ if api included into nested urls, we only care about last bit here
)
+ @property
def _get_urls(self) -> List[URLPattern]:
result = get_openapi_urls(self)
diff --git a/ninja/signature/details.py b/ninja/signature/details.py
index a680b72..632d187 100644
--- a/ninja/signature/details.py
+++ b/ninja/signature/details.py
@@ -129,17 +129,19 @@ class ViewSignature:
# 2) if param name is a part of the path parameter
elif name in self.path_params_names:
- assert arg.default == self.signature.empty, f"'{name}' is a path param"
+ assert (
+ arg.default == self.signature.empty
+ ), f"'{name}' is a path param, default not allowed"
param_source = params.Path(...)
- # 3) if param have no type annotation or annotation is not part of pydantic model:
+ # 3) if param is a collection or annotation is part of pydantic model:
elif is_collection or is_pydantic_model(annotation):
if arg.default == self.signature.empty:
param_source = params.Body(...)
else:
param_source = params.Body(arg.default)
- # 4) the last case is body param
+ # 4) the last case is query param
else:
if arg.default == self.signature.empty:
param_source = params.Query(...)
@@ -158,7 +160,12 @@ def is_pydantic_model(cls: Any) -> bool:
def is_collection_type(annotation: Any) -> bool:
origin = get_collection_origin(annotation)
- return origin in (List, list, set, tuple) # TODO: I gues we should handle only list
+ return origin in (
+ List,
+ list,
+ set,
+ tuple,
+ ) # TODO: I guess we should handle only list
def detect_pydantic_model_collection_fields(model: pydantic.BaseModel) -> List[str]:
diff --git a/ninja/signature/utils.py b/ninja/signature/utils.py
index 50e6827..fe46432 100644
--- a/ninja/signature/utils.py
+++ b/ninja/signature/utils.py
@@ -3,6 +3,8 @@ import inspect
import re
from typing import Any, Callable, Set
+from django.urls import register_converter
+from django.urls.converters import UUIDConverter
from pydantic.typing import ForwardRef, evaluate_forwardref
from ninja.types import DictStrAny
@@ -47,8 +49,8 @@ def make_forwardref(annotation: str, globalns: DictStrAny) -> Any:
def get_path_param_names(path: str) -> Set[str]:
- "turns path string like /foo/{var}/path/{another}/end to set ['var', 'another']"
- return {item.strip("{}") for item in re.findall("{[^}]*}", path)}
+ """turns path string like /foo/{var}/path/{int:another}/end to set {'var', 'another'}"""
+ return {item.strip("{}").split(":")[-1] for item in re.findall("{[^}]*}", path)}
def is_async(callable: Callable) -> bool:
@@ -62,3 +64,18 @@ def has_kwargs(call: Callable) -> bool:
if param.kind == param.VAR_KEYWORD:
return True
return False
+
+
+class NinjaUUIDConverter:
+ """Return a path converted UUID as a str instead of the standard UUID"""
+
+ regex = UUIDConverter.regex
+
+ def to_python(self, value: str) -> str:
+ return value
+
+ def to_url(self, value: Any) -> str:
+ return str(value)
+
+
+register_converter(NinjaUUIDConverter, "uuid")
| vitalik/django-ninja | 29d2b4741a1cd941384e650620ca81825d51efad | diff --git a/tests/main.py b/tests/main.py
index ab26e62..b2946df 100644
--- a/tests/main.py
+++ b/tests/main.py
@@ -1,3 +1,4 @@
+from uuid import UUID
from ninja import Router, Query, Path
@@ -131,6 +132,51 @@ def get_path_param_le_ge_int(request, item_id: int = Path(..., le=3, ge=1)):
return item_id
[email protected]("/path/param-django-str/{str:item_id}")
+def get_path_param_django_str(request, item_id):
+ return item_id
+
+
[email protected]("/path/param-django-int/{int:item_id}")
+def get_path_param_django_int(request, item_id:int):
+ assert isinstance(item_id, int)
+ return item_id
+
+
[email protected]("/path/param-django-int/not-an-int")
+def get_path_param_django_not_an_int(request):
+ """Verify that url resolution for get_path_param_django_int passes non-ints forward"""
+ return f"Found not-an-int"
+
+
[email protected]("/path/param-django-int-str/{int:item_id}")
+def get_path_param_django_int(request, item_id:str):
+ assert isinstance(item_id, str)
+ return item_id
+
+
[email protected]("/path/param-django-slug/{slug:item_id}")
+def get_path_param_django_slug(request, item_id):
+ return item_id
+
+
[email protected]("/path/param-django-uuid/{uuid:item_id}")
+def get_path_param_django_uuid(request, item_id: UUID):
+ assert isinstance(item_id, UUID)
+ return item_id
+
+
[email protected]("/path/param-django-uuid-str/{uuid:item_id}")
+def get_path_param_django_int(request, item_id):
+ assert isinstance(item_id, str)
+ return item_id
+
+
[email protected]("/path/param-django-path/{path:item_id}/after")
+def get_path_param_django_int(request, item_id):
+ return item_id
+
+
@router.get("/query")
def get_query(request, query):
return f"foo bar {query}"
@@ -175,3 +221,40 @@ def get_query_param_required(request, query=Query(...)):
@router.get("/query/param-required/int")
def get_query_param_required_type(request, query: int = Query(...)):
return f"foo bar {query}"
+
+
+class CustomPathConverter1:
+ regex = '[0-9]+'
+
+ def to_python(self, value) -> 'int':
+ """reverse the string and convert to int"""
+ return int(value[::-1])
+
+ def to_url(self, value):
+ return str(value)
+
+
+class CustomPathConverter2:
+ regex = "[0-9]+"
+
+ def to_python(self, value):
+ """reverse the string and convert to float like"""
+ return f"0.{value[::-1]}"
+
+ def to_url(self, value):
+ return str(value)
+
+
+from django.urls import register_converter
+register_converter(CustomPathConverter1, 'custom-int')
+register_converter(CustomPathConverter2, 'custom-float')
+
+
[email protected]("/path/param-django-custom-int/{custom-int:item_id}")
+def get_path_param_django_int(request, item_id: int):
+ return item_id
+
+
[email protected]("/path/param-django-custom-float/{custom-float:item_id}")
+def get_path_param_django_float(request, item_id:float):
+ return item_id
diff --git a/tests/test_path.py b/tests/test_path.py
index 4831587..0c44083 100644
--- a/tests/test_path.py
+++ b/tests/test_path.py
@@ -1,5 +1,6 @@
import pytest
from main import router
+from ninja import Router
from ninja.testing import TestClient
@@ -245,3 +246,69 @@ def test_get_path(path, expected_status, expected_response):
response = client.get(path)
assert response.status_code == expected_status
assert response.json() == expected_response
+
+
[email protected](
+ "path,expected_status,expected_response",
+ [
+ ("/path/param-django-str/42", 200, "42"),
+ ("/path/param-django-str/-1", 200, "-1"),
+ ("/path/param-django-str/foobar", 200, "foobar"),
+ ("/path/param-django-int/0", 200, 0),
+ ("/path/param-django-int/42", 200, 42),
+ ("/path/param-django-int/42.5", "Cannot resolve", Exception),
+ ("/path/param-django-int/-1", "Cannot resolve", Exception),
+ ("/path/param-django-int/True", "Cannot resolve", Exception),
+ ("/path/param-django-int/foobar", "Cannot resolve", Exception),
+ ("/path/param-django-int/not-an-int", 200, "Found not-an-int"),
+ ("/path/param-django-int-str/42", 200, '42'),
+ ("/path/param-django-int-str/42.5", "Cannot resolve", Exception),
+ (
+ "/path/param-django-slug/django-ninja-is-the-best",
+ 200,
+ "django-ninja-is-the-best",
+ ),
+ ("/path/param-django-slug/42.5", "Cannot resolve", Exception),
+ (
+ "/path/param-django-uuid/31ea378c-c052-4b4c-bf0b-679ce5cfcc2a",
+ 200,
+ "31ea378c-c052-4b4c-bf0b-679ce5cfcc2a",
+ ),
+ (
+ "/path/param-django-uuid/31ea378c-c052-4b4c-bf0b-679ce5cfcc2",
+ "Cannot resolve",
+ Exception,
+ ),
+ (
+ "/path/param-django-uuid-str/31ea378c-c052-4b4c-bf0b-679ce5cfcc2a",
+ 200,
+ "31ea378c-c052-4b4c-bf0b-679ce5cfcc2a",
+ ),
+ ("/path/param-django-path/some/path/things/after", 200, "some/path/things"),
+ ("/path/param-django-path/less/path/after", 200, "less/path"),
+ ("/path/param-django-path/plugh/after", 200, "plugh"),
+ ("/path/param-django-path//after", "Cannot resolve", Exception),
+ ("/path/param-django-custom-int/42", 200, 24),
+ ("/path/param-django-custom-int/x42", "Cannot resolve", Exception),
+ ("/path/param-django-custom-float/42", 200, 0.24),
+ ("/path/param-django-custom-float/x42", "Cannot resolve", Exception),
+ ],
+)
+def test_get_path_django(path, expected_status, expected_response):
+ if expected_response == Exception:
+ with pytest.raises(Exception, match=expected_status):
+ client.get(path)
+ else:
+ response = client.get(path)
+ assert response.status_code == expected_status
+ assert response.json() == expected_response
+
+
+def test_path_signature_asserts():
+ test_router = Router()
+
+ match = "'item_id' is a path param, default not allowed"
+ with pytest.raises(AssertionError, match=match):
+ @test_router.get("/path/{item_id}")
+ def get_path_item_id(request, item_id='1'):
+ pass
| Path param with converter(s)
Need to support Djaggo path converters
https://docs.djangoproject.com/en/3.1/topics/http/urls/#path-converters
basically this should work:
```Python
@api.get('/test-path/{path:page}')
def test_path(request, page):
return page
```
| 0.0 | 29d2b4741a1cd941384e650620ca81825d51efad | [
"tests/test_path.py::test_get_path_django[/path/param-django-str/42-200-42]",
"tests/test_path.py::test_get_path_django[/path/param-django-str/-1-200--1]",
"tests/test_path.py::test_get_path_django[/path/param-django-str/foobar-200-foobar]",
"tests/test_path.py::test_get_path_django[/path/param-django-int/0-200-0]",
"tests/test_path.py::test_get_path_django[/path/param-django-int/42-200-42]",
"tests/test_path.py::test_get_path_django[/path/param-django-int-str/42-200-42]",
"tests/test_path.py::test_get_path_django[/path/param-django-slug/django-ninja-is-the-best-200-django-ninja-is-the-best]",
"tests/test_path.py::test_get_path_django[/path/param-django-uuid/31ea378c-c052-4b4c-bf0b-679ce5cfcc2a-200-31ea378c-c052-4b4c-bf0b-679ce5cfcc2a]",
"tests/test_path.py::test_get_path_django[/path/param-django-uuid-str/31ea378c-c052-4b4c-bf0b-679ce5cfcc2a-200-31ea378c-c052-4b4c-bf0b-679ce5cfcc2a]",
"tests/test_path.py::test_get_path_django[/path/param-django-path/some/path/things/after-200-some/path/things]",
"tests/test_path.py::test_get_path_django[/path/param-django-path/less/path/after-200-less/path]",
"tests/test_path.py::test_get_path_django[/path/param-django-path/plugh/after-200-plugh]",
"tests/test_path.py::test_get_path_django[/path/param-django-custom-int/42-200-24]",
"tests/test_path.py::test_get_path_django[/path/param-django-custom-float/42-200-0.24]",
"tests/test_path.py::test_path_signature_asserts"
]
| [
"tests/test_path.py::test_text_get",
"tests/test_path.py::test_get_path[/path/foobar-200-foobar]",
"tests/test_path.py::test_get_path[/path/str/foobar-200-foobar]",
"tests/test_path.py::test_get_path[/path/str/42-200-42]",
"tests/test_path.py::test_get_path[/path/str/True-200-True]",
"tests/test_path.py::test_get_path[/path/int/foobar-422-expected_response4]",
"tests/test_path.py::test_get_path[/path/int/True-422-expected_response5]",
"tests/test_path.py::test_get_path[/path/int/42-200-42]",
"tests/test_path.py::test_get_path[/path/int/42.5-422-expected_response7]",
"tests/test_path.py::test_get_path[/path/float/foobar-422-expected_response8]",
"tests/test_path.py::test_get_path[/path/float/True-422-expected_response9]",
"tests/test_path.py::test_get_path[/path/float/42-200-42]",
"tests/test_path.py::test_get_path[/path/float/42.5-200-42.5]",
"tests/test_path.py::test_get_path[/path/bool/foobar-422-expected_response12]",
"tests/test_path.py::test_get_path[/path/bool/True-200-True]",
"tests/test_path.py::test_get_path[/path/bool/42-422-expected_response14]",
"tests/test_path.py::test_get_path[/path/bool/42.5-422-expected_response15]",
"tests/test_path.py::test_get_path[/path/bool/1-200-True]",
"tests/test_path.py::test_get_path[/path/bool/0-200-False]",
"tests/test_path.py::test_get_path[/path/bool/true-200-True]",
"tests/test_path.py::test_get_path[/path/bool/False-200-False]",
"tests/test_path.py::test_get_path[/path/bool/false-200-False]",
"tests/test_path.py::test_get_path[/path/param/foo-200-foo]",
"tests/test_path.py::test_get_path[/path/param-required/foo-200-foo]",
"tests/test_path.py::test_get_path[/path/param-minlength/foo-200-foo]",
"tests/test_path.py::test_get_path[/path/param-minlength/fo-422-expected_response24]",
"tests/test_path.py::test_get_path[/path/param-maxlength/foo-200-foo]",
"tests/test_path.py::test_get_path[/path/param-maxlength/foobar-422-expected_response26]",
"tests/test_path.py::test_get_path[/path/param-min_maxlength/foo-200-foo]",
"tests/test_path.py::test_get_path[/path/param-min_maxlength/foobar-422-expected_response28]",
"tests/test_path.py::test_get_path[/path/param-min_maxlength/f-422-expected_response29]",
"tests/test_path.py::test_get_path[/path/param-gt/42-200-42]",
"tests/test_path.py::test_get_path[/path/param-gt/2-422-expected_response31]",
"tests/test_path.py::test_get_path[/path/param-gt0/0.05-200-0.05]",
"tests/test_path.py::test_get_path[/path/param-gt0/0-422-expected_response33]",
"tests/test_path.py::test_get_path[/path/param-ge/42-200-42]",
"tests/test_path.py::test_get_path[/path/param-ge/3-200-3]",
"tests/test_path.py::test_get_path[/path/param-ge/2-422-expected_response36]",
"tests/test_path.py::test_get_path[/path/param-lt/42-422-expected_response37]",
"tests/test_path.py::test_get_path[/path/param-lt/2-200-2]",
"tests/test_path.py::test_get_path[/path/param-lt0/-1-200--1]",
"tests/test_path.py::test_get_path[/path/param-lt0/0-422-expected_response40]",
"tests/test_path.py::test_get_path[/path/param-le/42-422-expected_response41]",
"tests/test_path.py::test_get_path[/path/param-le/3-200-3]",
"tests/test_path.py::test_get_path[/path/param-le/2-200-2]",
"tests/test_path.py::test_get_path[/path/param-lt-gt/2-200-2]",
"tests/test_path.py::test_get_path[/path/param-lt-gt/4-422-expected_response45]",
"tests/test_path.py::test_get_path[/path/param-lt-gt/0-422-expected_response46]",
"tests/test_path.py::test_get_path[/path/param-le-ge/2-200-2]",
"tests/test_path.py::test_get_path[/path/param-le-ge/1-200-1]",
"tests/test_path.py::test_get_path[/path/param-le-ge/3-200-3]",
"tests/test_path.py::test_get_path[/path/param-le-ge/4-422-expected_response50]",
"tests/test_path.py::test_get_path[/path/param-lt-int/2-200-2]",
"tests/test_path.py::test_get_path[/path/param-lt-int/42-422-expected_response52]",
"tests/test_path.py::test_get_path[/path/param-lt-int/2.7-422-expected_response53]",
"tests/test_path.py::test_get_path[/path/param-gt-int/42-200-42]",
"tests/test_path.py::test_get_path[/path/param-gt-int/2-422-expected_response55]",
"tests/test_path.py::test_get_path[/path/param-gt-int/2.7-422-expected_response56]",
"tests/test_path.py::test_get_path[/path/param-le-int/42-422-expected_response57]",
"tests/test_path.py::test_get_path[/path/param-le-int/3-200-3]",
"tests/test_path.py::test_get_path[/path/param-le-int/2-200-2]",
"tests/test_path.py::test_get_path[/path/param-le-int/2.7-422-expected_response60]",
"tests/test_path.py::test_get_path[/path/param-ge-int/42-200-42]",
"tests/test_path.py::test_get_path[/path/param-ge-int/3-200-3]",
"tests/test_path.py::test_get_path[/path/param-ge-int/2-422-expected_response63]",
"tests/test_path.py::test_get_path[/path/param-ge-int/2.7-422-expected_response64]",
"tests/test_path.py::test_get_path[/path/param-lt-gt-int/2-200-2]",
"tests/test_path.py::test_get_path[/path/param-lt-gt-int/4-422-expected_response66]",
"tests/test_path.py::test_get_path[/path/param-lt-gt-int/0-422-expected_response67]",
"tests/test_path.py::test_get_path[/path/param-lt-gt-int/2.7-422-expected_response68]",
"tests/test_path.py::test_get_path[/path/param-le-ge-int/2-200-2]",
"tests/test_path.py::test_get_path[/path/param-le-ge-int/1-200-1]",
"tests/test_path.py::test_get_path[/path/param-le-ge-int/3-200-3]",
"tests/test_path.py::test_get_path[/path/param-le-ge-int/4-422-expected_response72]",
"tests/test_path.py::test_get_path[/path/param-le-ge-int/2.7-422-expected_response73]",
"tests/test_path.py::test_get_path_django[/path/param-django-int/42.5-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-int/-1-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-int/True-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-int/foobar-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-int/not-an-int-200-Found",
"tests/test_path.py::test_get_path_django[/path/param-django-int-str/42.5-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-slug/42.5-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-uuid/31ea378c-c052-4b4c-bf0b-679ce5cfcc2-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-path/after-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-custom-int/x42-Cannot",
"tests/test_path.py::test_get_path_django[/path/param-django-custom-float/x42-Cannot"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false
} | 2021-07-29 04:55:31+00:00 | mit | 6,204 |
|
vitalik__django-ninja-237 | diff --git a/ninja/openapi/schema.py b/ninja/openapi/schema.py
index 9232f18..795f0d1 100644
--- a/ninja/openapi/schema.py
+++ b/ninja/openapi/schema.py
@@ -230,12 +230,9 @@ class OpenAPISchema(dict):
if len(models) == 1:
model = models[0]
content_type = BODY_CONTENT_TYPES[model._param_source]
- if model._param_source == "file":
- schema, required = self._create_schema_from_model(
- model, remove_level=False
- )
- else:
- schema, required = self._create_schema_from_model(model)
+ schema, required = self._create_schema_from_model(
+ model, remove_level=model._param_source == "body"
+ )
else:
schema, content_type = self._create_multipart_schema_from_models(models)
required = True
| vitalik/django-ninja | 6e6e13ff1a44a855c0375049e949bf9935667edb | diff --git a/tests/test_openapi_schema.py b/tests/test_openapi_schema.py
index ba83386..537ba7a 100644
--- a/tests/test_openapi_schema.py
+++ b/tests/test_openapi_schema.py
@@ -62,6 +62,11 @@ def method_form(request, data: Payload = Form(...)):
return dict(i=data.i, f=data.f)
[email protected]("/test-form-single", response=Response)
+def method_form_single(request, data: float = Form(...)):
+ return dict(i=int(data), f=data)
+
+
@api.post("/test-form-body", response=Response)
def method_form_body(request, i: int = Form(10), s: str = Body("10")):
return dict(i=i, s=s)
@@ -358,6 +363,34 @@ def test_schema_form(schema):
}
+def test_schema_single(schema):
+ method_list = schema["paths"]["/api/test-form-single"]["post"]
+
+ assert method_list["requestBody"] == {
+ "content": {
+ "application/x-www-form-urlencoded": {
+ "schema": {
+ "properties": {"data": {"title": "Data", "type": "number"}},
+ "required": ["data"],
+ "title": "FormParams",
+ "type": "object",
+ }
+ }
+ },
+ "required": True,
+ }
+ assert method_list["responses"] == {
+ 200: {
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "schema": {"$ref": "#/components/schemas/Response"}
+ }
+ },
+ }
+ }
+
+
def test_schema_form_body(schema):
method_list = schema["paths"]["/api/test-form-body"]["post"]
diff --git a/tests/test_wraps.py b/tests/test_wraps.py
index 69b0ee6..98fd0c4 100644
--- a/tests/test_wraps.py
+++ b/tests/test_wraps.py
@@ -1,4 +1,5 @@
from functools import wraps
+from unittest import mock
import pytest
@@ -60,10 +61,12 @@ def get_text_bad(request):
return "Hello World"
[email protected]("/path-bad/{item_id}")
-@a_bad_test_wrapper
-def get_id_bad(request, item_id):
- return item_id
+with mock.patch("ninja.signature.details.warnings.warn_explicit"):
+
+ @router.get("/path-bad/{item_id}")
+ @a_bad_test_wrapper
+ def get_id_bad(request, item_id):
+ return item_id
@router.get("/query-bad")
@@ -72,10 +75,12 @@ def get_query_type_bad(request, query: int):
return f"foo bar {query}"
[email protected]("/path-query-bad/{item_id}")
-@a_bad_test_wrapper
-def get_query_id_bad(request, item_id, query: int):
- return f"foo bar {item_id} {query}"
+with mock.patch("ninja.signature.details.warnings.warn_explicit"):
+
+ @router.get("/path-query-bad/{item_id}")
+ @a_bad_test_wrapper
+ def get_query_id_bad(request, item_id, query: int):
+ return f"foo bar {item_id} {query}"
@pytest.mark.parametrize(
| Schema doesn't render properly

Code:
```python
def forgot_password(request: HttpRequest, email: EmailStr = Form(...)):
...
# And
def reset_password(
request: HttpRequest,
token: str,
password: constr(strip_whitespace=True, min_length=8) = Form(...),
):
...
```
| 0.0 | 6e6e13ff1a44a855c0375049e949bf9935667edb | [
"tests/test_openapi_schema.py::test_schema_single"
]
| [
"tests/test_openapi_schema.py::test_schema_views",
"tests/test_openapi_schema.py::test_schema_views_no_INSTALLED_APPS",
"tests/test_openapi_schema.py::test_schema",
"tests/test_openapi_schema.py::test_schema_alias",
"tests/test_openapi_schema.py::test_schema_list",
"tests/test_openapi_schema.py::test_schema_body",
"tests/test_openapi_schema.py::test_schema_body_schema",
"tests/test_openapi_schema.py::test_schema_path",
"tests/test_openapi_schema.py::test_schema_form",
"tests/test_openapi_schema.py::test_schema_form_body",
"tests/test_openapi_schema.py::test_schema_form_file",
"tests/test_openapi_schema.py::test_schema_body_file",
"tests/test_openapi_schema.py::test_get_openapi_urls",
"tests/test_openapi_schema.py::test_unique_operation_ids",
"tests/test_wraps.py::test_get_path[/text-200-Hello",
"tests/test_wraps.py::test_get_path[/path/id-200-id]",
"tests/test_wraps.py::test_get_path[/query?query=1-200-foo",
"tests/test_wraps.py::test_get_path[/path-query/id?query=2-200-foo",
"tests/test_wraps.py::test_get_path[/text-bad-200-Hello",
"tests/test_wraps.py::test_get_path[/path-bad/id-None-TypeError]",
"tests/test_wraps.py::test_get_path[/query-bad?query=1-None-TypeError]",
"tests/test_wraps.py::test_get_path[/path-query-bad/id?query=2-None-TypeError]"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks",
"has_media"
],
"has_test_patch": true,
"is_lite": false
} | 2021-10-04 14:39:58+00:00 | mit | 6,205 |
|
vitalik__django-ninja-317 | diff --git a/docs/docs/tutorial/response-schema.md b/docs/docs/tutorial/response-schema.md
index fdfbc23..fecd511 100644
--- a/docs/docs/tutorial/response-schema.md
+++ b/docs/docs/tutorial/response-schema.md
@@ -90,7 +90,7 @@ class TaskSchema(Schema):
@api.get("/tasks", response=List[TaskSchema])
def tasks(request):
- queryset = Task.objects.all()
+ queryset = Task.objects.select_related("owner")
return list(queryset)
```
@@ -117,6 +117,59 @@ If you execute this operation, you should get a response like this:
]
```
+
+## Aliases
+
+Instead of a nested response, you may want to just flatten the response output.
+The Ninja `Schema` object extends Pydantic's `Field(..., alias="")` format to
+work with dotted responses.
+
+Using the models from above, let's make a schema that just includes the task
+owner's first name inline, and also uses `completed` rather than `is_completed`:
+
+```Python hl_lines="1 7-9"
+from ninja import Field, Schema
+
+
+class TaskSchema(Schema):
+ id: int
+ title: str
+ # The first Field param is the default, use ... for required fields.
+ completed: bool = Field(..., alias="is_completed)
+ owner_first_name: str = Field(None, alias="owner.first_name")
+```
+
+
+## Resolvers
+
+You can also create calculated fields via resolve methods based on the field
+name.
+
+The method must accept a single argument, which will be the object the schema
+is resolving against.
+
+When creating a resolver as a standard method, `self` gives you access to other
+validated and formatted attributes in the schema.
+
+```Python hl_lines="5 7-11"
+class TaskSchema(Schema):
+ id: int
+ title: str
+ is_completed: bool
+ owner: Optional[str]
+ lower_title: str
+
+ @staticmethod
+ def resolve_owner(obj):
+ if not obj.owner:
+ return
+ return f"{obj.owner.first_name} {obj.owner.last_name}"
+
+ def resolve_lower_title(self, obj):
+ return self.title.lower()
+```
+
+
## Returning querysets
In the previous example we specifically converted a queryset into a list (and executed the SQL query during evaluation).
diff --git a/ninja/orm/metaclass.py b/ninja/orm/metaclass.py
index 652b34c..1300238 100644
--- a/ninja/orm/metaclass.py
+++ b/ninja/orm/metaclass.py
@@ -1,16 +1,15 @@
from typing import no_type_check
from django.db.models import Model as DjangoModel
-from pydantic.main import ModelMetaclass
from ninja.errors import ConfigError
from ninja.orm.factory import create_schema
-from ninja.schema import Schema
+from ninja.schema import ResolverMetaclass, Schema
_is_modelschema_class_defined = False
-class ModelSchemaMetaclass(ModelMetaclass):
+class ModelSchemaMetaclass(ResolverMetaclass):
@no_type_check
def __new__(
mcs,
diff --git a/ninja/schema.py b/ninja/schema.py
index 73b762f..b86a722 100644
--- a/ninja/schema.py
+++ b/ninja/schema.py
@@ -1,9 +1,33 @@
-from typing import Any
+"""
+Since "Model" word would be very confusing when used in django context, this
+module basically makes an alias for it named "Schema" and adds extra whistles to
+be able to work with django querysets and managers.
+
+The schema is a bit smarter than a standard pydantic Model because it can handle
+dotted attributes and resolver methods. For example::
+
+
+ class UserSchema(User):
+ name: str
+ initials: str
+ boss: str = Field(None, alias="boss.first_name")
+
+ @staticmethod
+ def resolve_name(obj):
+ return f"{obj.first_name} {obj.last_name}"
+
+ def resolve_initials(self, obj):
+ return "".join(n[:1] for n in self.name.split())
+
+"""
+from operator import attrgetter
+from typing import Any, Callable, Dict, Type, TypeVar, Union, no_type_check
import pydantic
from django.db.models import Manager, QuerySet
from django.db.models.fields.files import FieldFile
from pydantic import BaseModel, Field, validator
+from pydantic.main import ModelMetaclass
from pydantic.utils import GetterDict
pydantic_version = list(map(int, pydantic.VERSION.split(".")[:2]))
@@ -11,16 +35,37 @@ assert pydantic_version >= [1, 6], "Pydantic 1.6+ required"
__all__ = ["BaseModel", "Field", "validator", "DjangoGetter", "Schema"]
-
-# Since "Model" word would be very confusing when used in django context
-# this module basically makes alias for it named "Schema"
-# and ads extra whistles to be able to work with django querysets and managers
+S = TypeVar("S", bound="Schema")
class DjangoGetter(GetterDict):
+ __slots__ = ("_obj", "_schema_cls")
+
+ def __init__(self, obj: Any, schema_cls: "Type[Schema]"):
+ self._obj = obj
+ self._schema_cls = schema_cls
+
+ def __getitem__(self, key: str) -> Any:
+ resolver = self._schema_cls._ninja_resolvers.get(key)
+ if resolver:
+ item = resolver(getter=self)
+ else:
+ try:
+ item = getattr(self._obj, key)
+ except AttributeError:
+ try:
+ item = attrgetter(key)(self._obj)
+ except AttributeError as e:
+ raise KeyError(key) from e
+ return self.format_result(item)
+
def get(self, key: Any, default: Any = None) -> Any:
- result = super().get(key, default)
+ try:
+ return self[key]
+ except KeyError:
+ return default
+ def format_result(self, result: Any) -> Any:
if isinstance(result, Manager):
return list(result.all())
@@ -35,7 +80,87 @@ class DjangoGetter(GetterDict):
return result
-class Schema(BaseModel):
+class Resolver:
+ __slots__ = ("_func", "_static")
+ _static: bool
+ _func: Any
+
+ def __init__(self, func: Union[Callable, staticmethod]):
+ if isinstance(func, staticmethod):
+ self._static = True
+ self._func = func.__func__
+ else:
+ self._static = False
+ self._func = func
+
+ def __call__(self, getter: DjangoGetter) -> Any:
+ if self._static:
+ return self._func(getter._obj)
+ return self._func(self._fake_instance(getter), getter._obj)
+
+ def _fake_instance(self, getter: DjangoGetter) -> "Schema":
+ """
+ Generate a partial schema instance that can be used as the ``self``
+ attribute of resolver functions.
+ """
+
+ class PartialSchema(Schema):
+ def __getattr__(self, key: str) -> Any:
+ value = getter[key]
+ field = getter._schema_cls.__fields__[key]
+ value = field.validate(value, values={}, loc=key, cls=None)[0]
+ return value
+
+ return PartialSchema()
+
+
+class ResolverMetaclass(ModelMetaclass):
+ _ninja_resolvers: Dict[str, Resolver]
+
+ @no_type_check
+ def __new__(cls, name, bases, namespace, **kwargs):
+ resolvers = {}
+
+ for base in reversed(bases):
+ base_resolvers = getattr(base, "_ninja_resolvers", None)
+ if base_resolvers:
+ resolvers.update(base_resolvers)
+ for attr, resolve_func in namespace.items():
+ if not attr.startswith("resolve_"):
+ continue
+ if (
+ not callable(resolve_func)
+ # A staticmethod isn't directly callable in Python <=3.9.
+ and not isinstance(resolve_func, staticmethod)
+ ):
+ continue
+ resolvers[attr[8:]] = Resolver(resolve_func)
+
+ result = super().__new__(cls, name, bases, namespace, **kwargs)
+ result._ninja_resolvers = resolvers
+ return result
+
+
+class Schema(BaseModel, metaclass=ResolverMetaclass):
class Config:
orm_mode = True
getter_dict = DjangoGetter
+
+ @classmethod
+ def from_orm(cls: Type[S], obj: Any) -> S:
+ getter_dict = cls.__config__.getter_dict
+ obj = (
+ # DjangoGetter also needs the class so it can find resolver methods.
+ getter_dict(obj, cls)
+ if issubclass(getter_dict, DjangoGetter)
+ else getter_dict(obj)
+ )
+ return super().from_orm(obj)
+
+ @classmethod
+ def _decompose_class(cls, obj: Any) -> GetterDict:
+ # This method has backported logic from Pydantic 1.9 and is no longer
+ # needed once that is the minimum version.
+ if isinstance(obj, GetterDict):
+ return obj
+ return super()._decompose_class(obj) # pragma: no cover
| vitalik/django-ninja | fc00cad403354637f59af01b7f4e6d38685a3fb3 | diff --git a/tests/test_schema.py b/tests/test_schema.py
index fa68982..0ae5d02 100644
--- a/tests/test_schema.py
+++ b/tests/test_schema.py
@@ -1,4 +1,4 @@
-from typing import List
+from typing import List, Optional
from unittest.mock import Mock
from django.db.models import Manager, QuerySet
@@ -34,11 +34,16 @@ class Tag:
self.title = title
-# mocking some user:
+# mocking some users:
+class Boss:
+ name = "Jane Jackson"
+
+
class User:
- name = "John"
+ name = "John Smith"
group_set = FakeManager([1, 2, 3])
avatar = ImageFieldFile(None, Mock(), name=None)
+ boss: Optional[Boss] = Boss()
@property
def tags(self):
@@ -57,11 +62,27 @@ class UserSchema(Schema):
avatar: str = None
+class UserWithBossSchema(UserSchema):
+ boss: Optional[str] = Field(None, alias="boss.name")
+ has_boss: bool
+
+ @staticmethod
+ def resolve_has_boss(obj):
+ return bool(obj.boss)
+
+
+class UserWithInitialsSchema(UserWithBossSchema):
+ initials: str
+
+ def resolve_initials(self, obj):
+ return "".join(n[:1] for n in self.name.split())
+
+
def test_schema():
user = User()
schema = UserSchema.from_orm(user)
assert schema.dict() == {
- "name": "John",
+ "name": "John Smith",
"groups": [1, 2, 3],
"tags": [{"id": "1", "title": "foo"}, {"id": "2", "title": "bar"}],
"avatar": None,
@@ -75,8 +96,47 @@ def test_schema_with_image():
user.avatar = ImageFieldFile(None, field, name="smile.jpg")
schema = UserSchema.from_orm(user)
assert schema.dict() == {
- "name": "John",
+ "name": "John Smith",
"groups": [1, 2, 3],
"tags": [{"id": "1", "title": "foo"}, {"id": "2", "title": "bar"}],
"avatar": "/smile.jpg",
}
+
+
+def test_with_boss_schema():
+ user = User()
+ schema = UserWithBossSchema.from_orm(user)
+ assert schema.dict() == {
+ "name": "John Smith",
+ "boss": "Jane Jackson",
+ "has_boss": True,
+ "groups": [1, 2, 3],
+ "tags": [{"id": "1", "title": "foo"}, {"id": "2", "title": "bar"}],
+ "avatar": None,
+ }
+
+ user_without_boss = User()
+ user_without_boss.boss = None
+ schema = UserWithBossSchema.from_orm(user_without_boss)
+ assert schema.dict() == {
+ "name": "John Smith",
+ "boss": None,
+ "has_boss": False,
+ "groups": [1, 2, 3],
+ "tags": [{"id": "1", "title": "foo"}, {"id": "2", "title": "bar"}],
+ "avatar": None,
+ }
+
+
+def test_with_initials_schema():
+ user = User()
+ schema = UserWithInitialsSchema.from_orm(user)
+ assert schema.dict() == {
+ "name": "John Smith",
+ "initials": "JS",
+ "boss": "Jane Jackson",
+ "has_boss": True,
+ "groups": [1, 2, 3],
+ "tags": [{"id": "1", "title": "foo"}, {"id": "2", "title": "bar"}],
+ "avatar": None,
+ }
| Foreign key field value instead of id without nesting schemas ?
Hi, is it possible to send a foreign key value without nesting the schemas ? Here's my scenario:
```python
class Department(models.Model):
id = models.IntegerField(primarty_key=True, editable=False)
dep = models.CharField(max_length=200, null=False,unique=True)
class Student(models.Model):
id = models.IntegerField(primarty_key=True, editable=False)
name = models.CharField(max_length=200, null=False)
dep = models.ForeignKey(Department, on_delete=models.CASCADE)
class DepartmentOut(Schema):
dep: str
class StudentOut(Schema):
id: int
name: str
dep: DepartmentOut
```
this will result in an output of:
```python
{
id: 1000,
name: 'Some name',
dep: {
dep: 'Some Text'
}
}
```
How can I show the dep string without a nested object called dep? Like the below shape of JSON:
```python
{
id: 1000,
name: 'Some name',
dep: 'Some Text'
}
```
I tried searching without any luck, thanks in advance. | 0.0 | fc00cad403354637f59af01b7f4e6d38685a3fb3 | [
"tests/test_schema.py::test_with_boss_schema",
"tests/test_schema.py::test_with_initials_schema"
]
| [
"tests/test_schema.py::test_schema",
"tests/test_schema.py::test_schema_with_image"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-01-09 03:40:27+00:00 | mit | 6,206 |
|
vitalik__django-ninja-336 | diff --git a/docs/docs/tutorial/temporal_response.md b/docs/docs/tutorial/temporal_response.md
new file mode 100644
index 0000000..e767441
--- /dev/null
+++ b/docs/docs/tutorial/temporal_response.md
@@ -0,0 +1,38 @@
+# Altering the Response
+
+Sometimes you'll want to change the response just before it gets served, for example, to add a header or alter a cookie.
+
+To do this, simply declare a function parameter with a type of `HttpResponse`:
+
+```Python
+from django.http import HttpRequest, HttpResponse
+
[email protected]("/cookie/")
+def feed_cookiemonster(request: HttpRequest, response: HttpResponse):
+ # Set a cookie.
+ response.set_cookie("cookie", "delicious")
+ # Set a header.
+ response["X-Cookiemonster"] = "blue"
+ return {"cookiemonster_happy": True}
+```
+
+
+## Temporal response object
+
+This response object is used for the base of all responses built by Django Ninja, including error responses. This object is *not* used if a Django `HttpResponse` object is returned directly by an operation.
+
+Obviously this response object won't contain the content yet, but it does have the `content_type` set (but you probably don't want to be changing it).
+
+The `status_code` will get overridden depending on the return value (200 by default, or the status code if a two-part tuple is returned).
+
+
+## Changing the base response object
+
+You can alter this temporal response object by overriding the `NinjaAPI.create_temporal_response` method.
+
+```Python
+ def create_temporal_response(self, request: HttpRequest) -> HttpResponse:
+ response = super().create_temporal_response(request)
+ # Do your magic here...
+ return response
+```
\ No newline at end of file
diff --git a/ninja/main.py b/ninja/main.py
index fbf540e..27ba4d6 100644
--- a/ninja/main.py
+++ b/ninja/main.py
@@ -335,13 +335,34 @@ class NinjaAPI:
return reverse(name)
def create_response(
- self, request: HttpRequest, data: Any, *, status: int = 200
+ self,
+ request: HttpRequest,
+ data: Any,
+ *,
+ status: int = None,
+ temporal_response: HttpResponse = None,
) -> HttpResponse:
+ if temporal_response:
+ status = temporal_response.status_code
+ assert status
+
content = self.renderer.render(request, data, response_status=status)
- content_type = "{}; charset={}".format(
- self.renderer.media_type, self.renderer.charset
- )
- return HttpResponse(content, status=status, content_type=content_type)
+
+ if temporal_response:
+ response = temporal_response
+ response.content = content
+ else:
+ response = HttpResponse(
+ content, status=status, content_type=self.get_content_type()
+ )
+
+ return response
+
+ def create_temporal_response(self, request: HttpRequest) -> HttpResponse:
+ return HttpResponse("", content_type=self.get_content_type())
+
+ def get_content_type(self) -> str:
+ return "{}; charset={}".format(self.renderer.media_type, self.renderer.charset)
def get_openapi_schema(self, path_prefix: Optional[str] = None) -> OpenAPISchema:
if path_prefix is None:
diff --git a/ninja/operation.py b/ninja/operation.py
index 2fa0935..dcdb955 100644
--- a/ninja/operation.py
+++ b/ninja/operation.py
@@ -94,9 +94,10 @@ class Operation:
if error:
return error
try:
- values = self._get_values(request, kw)
+ temporal_response = self.api.create_temporal_response(request)
+ values = self._get_values(request, kw, temporal_response)
result = self.view_func(request, **values)
- return self._result_to_response(request, result)
+ return self._result_to_response(request, result, temporal_response)
except Exception as e:
if isinstance(e, TypeError) and "required positional argument" in str(e):
msg = "Did you fail to use functools.wraps() in a decorator?"
@@ -151,7 +152,7 @@ class Operation:
return self.api.create_response(request, {"detail": "Unauthorized"}, status=401)
def _result_to_response(
- self, request: HttpRequest, result: Any
+ self, request: HttpRequest, result: Any, temporal_response: HttpResponse
) -> HttpResponseBase:
"""
The protocol for results
@@ -179,13 +180,16 @@ class Operation:
f"Schema for status {status} is not set in response {self.response_models.keys()}"
)
+ temporal_response.status_code = status
+
if response_model is NOT_SET:
- return self.api.create_response(request, result, status=status)
+ return self.api.create_response(
+ request, result, temporal_response=temporal_response
+ )
if response_model is None:
- return HttpResponse(status=status)
- # TODO: ^ maybe self.api.create_empty_response ?
- # return self.api.create_response(request, result, status=status)
+ # Empty response.
+ return temporal_response
resp_object = ResponseObject(result)
# ^ we need object because getter_dict seems work only with from_orm
@@ -195,9 +199,13 @@ class Operation:
exclude_defaults=self.exclude_defaults,
exclude_none=self.exclude_none,
)["response"]
- return self.api.create_response(request, result, status=status)
+ return self.api.create_response(
+ request, result, temporal_response=temporal_response
+ )
- def _get_values(self, request: HttpRequest, path_params: Any) -> DictStrAny:
+ def _get_values(
+ self, request: HttpRequest, path_params: Any, temporal_response: HttpResponse
+ ) -> DictStrAny:
values, errors = {}, []
for model in self.models:
try:
@@ -213,6 +221,8 @@ class Operation:
errors.extend(items)
if errors:
raise ValidationError(errors)
+ if self.signature.response_arg:
+ values[self.signature.response_arg] = temporal_response
return values
def _create_response_model_multiple(
@@ -244,9 +254,10 @@ class AsyncOperation(Operation):
if error:
return error
try:
- values = self._get_values(request, kw)
+ temporal_response = self.api.create_temporal_response(request)
+ values = self._get_values(request, kw, temporal_response)
result = await self.view_func(request, **values)
- return self._result_to_response(request, result)
+ return self._result_to_response(request, result, temporal_response)
except Exception as e:
return self.api.on_exception(request, e)
diff --git a/ninja/signature/details.py b/ninja/signature/details.py
index 4aea69d..a740684 100644
--- a/ninja/signature/details.py
+++ b/ninja/signature/details.py
@@ -1,9 +1,10 @@
import inspect
import warnings
from collections import defaultdict, namedtuple
-from typing import Any, Callable, Dict, Generator, List, Tuple, Union
+from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union
import pydantic
+from django.http import HttpResponse
from ninja import UploadedFile, params
from ninja.compatibility.util import get_args, get_origin as get_collection_origin
@@ -28,6 +29,7 @@ class ViewSignature:
FLATTEN_PATH_SEP = (
"\x1e" # ASCII Record Separator. IE: not generally used in query names
)
+ response_arg: Optional[str] = None
def __init__(self, path: str, view_func: Callable) -> None:
self.view_func = view_func
@@ -54,6 +56,10 @@ class ViewSignature:
# Skipping *args
continue
+ if arg.annotation is HttpResponse:
+ self.response_arg = name
+ continue
+
func_param = self._get_param_type(name, arg)
self.params.append(func_param)
| vitalik/django-ninja | e9f369883f88517a551e304e1ee2e199cad0dd2d | diff --git a/ninja/testing/client.py b/ninja/testing/client.py
index a50db15..b471bfb 100644
--- a/ninja/testing/client.py
+++ b/ninja/testing/client.py
@@ -1,5 +1,6 @@
+from http import cookies
from json import dumps as json_dumps, loads as json_loads
-from typing import Any, Callable, Dict, List, Optional, Tuple, Union
+from typing import Any, Callable, Dict, List, Optional, Tuple, Union, cast
from unittest.mock import Mock
from urllib.parse import urljoin
@@ -169,5 +170,10 @@ class NinjaResponse:
def __getitem__(self, key: str) -> Any:
return self._response[key]
+ @property
+ def cookies(self) -> cookies.SimpleCookie:
+ return cast(cookies.SimpleCookie, self._response.cookies)
+
def __getattr__(self, attr: str) -> Any:
return getattr(self._response, attr)
+
diff --git a/tests/test_response.py b/tests/test_response.py
index 0ec9ffe..7d2ae3d 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -1,6 +1,7 @@
from typing import List, Union
import pytest
+from django.http import HttpResponse
from pydantic import BaseModel, ValidationError
from ninja import Router
@@ -65,6 +66,25 @@ def check_union(request, q: int):
return "invalid"
[email protected]("/check_set_header")
+def check_set_header(request, response: HttpResponse):
+ response["Cache-Control"] = "no-cache"
+ return 1
+
+
[email protected]("/check_set_cookie")
+def check_set_cookie(request, set: bool, response: HttpResponse):
+ if set:
+ response.set_cookie("test", "me")
+ return 1
+
+
[email protected]("/check_del_cookie")
+def check_del_cookie(request, response: HttpResponse):
+ response.delete_cookie("test")
+ return 1
+
+
client = TestClient(router)
@@ -95,3 +115,28 @@ def test_validates():
with pytest.raises(ValidationError):
client.get("/check_union?q=2")
+
+
+def test_set_header():
+ response = client.get("/check_set_header")
+ assert response.status_code == 200
+ assert response.content == b"1"
+ assert response["Cache-Control"] == "no-cache"
+
+
+def test_set_cookie():
+ response = client.get("/check_set_cookie?set=0")
+ assert "test" not in response.cookies
+
+ response = client.get("/check_set_cookie?set=1")
+ cookie = response.cookies.get("test")
+ assert cookie
+ assert cookie.value == "me"
+
+
+def test_del_cookie():
+ response = client.get("/check_del_cookie")
+ cookie = response.cookies.get("test")
+ assert cookie
+ assert cookie["expires"] == "Thu, 01 Jan 1970 00:00:00 GMT"
+ assert cookie["max-age"] == 0
| Provide a way to specify response headers
Seems like currently [Operation._result_to_response](https://github.com/vitalik/django-ninja/blob/5a19d230cb451f1f3ab0e167460bc05f49a6554e/ninja/operation.py#L106-L135) do not expect response headers from view function result (if not already part of `HttpResponse` instance).
This makes passing response headers tedious task.
Maybe `django-ninja` should allow view handler to setup response headers,
1. Via [temporal Response instance](https://fastapi.tiangolo.com/advanced/response-headers/) as done in FastAPI
2. Or via [last tuple item](https://flask.palletsprojects.com/en/1.1.x/quickstart/#about-responses) as done in Flask
What do you think? | 0.0 | e9f369883f88517a551e304e1ee2e199cad0dd2d | [
"tests/test_response.py::test_responses[/check_int-1]",
"tests/test_response.py::test_responses[/check_model-expected_response1]",
"tests/test_response.py::test_responses[/check_list_model-expected_response2]",
"tests/test_response.py::test_responses[/check_model-expected_response3]",
"tests/test_response.py::test_responses[/check_model_alias-expected_response4]",
"tests/test_response.py::test_responses[/check_union?q=0-1]",
"tests/test_response.py::test_responses[/check_union?q=1-expected_response6]",
"tests/test_response.py::test_validates",
"tests/test_response.py::test_set_header",
"tests/test_response.py::test_set_cookie",
"tests/test_response.py::test_del_cookie"
]
| []
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-01-27 04:46:02+00:00 | mit | 6,207 |
|
vitalik__django-ninja-434 | diff --git a/ninja/signature/details.py b/ninja/signature/details.py
index 8ef6d56..3e91f8d 100644
--- a/ninja/signature/details.py
+++ b/ninja/signature/details.py
@@ -252,7 +252,11 @@ def is_collection_type(annotation: Any) -> bool:
origin = get_collection_origin(annotation)
types = (List, list, set, tuple)
if origin is None:
- return issubclass(annotation, types)
+ return (
+ isinstance(annotation, types)
+ if not isinstance(annotation, type)
+ else issubclass(annotation, types)
+ )
else:
return origin in types # TODO: I guess we should handle only list
| vitalik/django-ninja | 99281903cfd4db19fd462e875d87e6edace038fc | diff --git a/tests/test_signature_details.py b/tests/test_signature_details.py
new file mode 100644
index 0000000..c48f84f
--- /dev/null
+++ b/tests/test_signature_details.py
@@ -0,0 +1,48 @@
+import typing
+from sys import version_info
+
+import pytest
+
+from ninja.signature.details import is_collection_type
+
+
[email protected](
+ ("annotation", "expected"),
+ [
+ pytest.param(typing.List, True, id="true_for_typing_List"),
+ pytest.param(list, True, id="true_for_native_list"),
+ pytest.param(typing.Set, True, id="true_for_typing_Set"),
+ pytest.param(set, True, id="true_for_native_set"),
+ pytest.param(typing.Tuple, True, id="true_for_typing_Tuple"),
+ pytest.param(tuple, True, id="true_for_native_tuple"),
+ pytest.param(
+ type("Custom", (), {}),
+ False,
+ id="false_for_custom_type_without_typing_origin",
+ ),
+ pytest.param(
+ object(), False, id="false_for_custom_instance_without_typing_origin"
+ ),
+ pytest.param(
+ typing.NewType("SomethingNew", str),
+ False,
+ id="false_for_instance_without_typing_origin",
+ ),
+ # Can't mark with `pytest.mark.skipif` since we'd attempt to instantiate the
+ # parameterized value/type(e.g. `list[int]`). Which only works with Python >= 3.9)
+ *(
+ (
+ pytest.param(list[int], True, id="true_for_parameterized_native_list"),
+ pytest.param(set[int], True, id="true_for_parameterized_native_set"),
+ pytest.param(
+ tuple[int], True, id="true_for_parameterized_native_tuple"
+ ),
+ )
+ # TODO: Remove conditional once support for <=3.8 is dropped
+ if version_info >= (3, 9)
+ else ()
+ ),
+ ],
+)
+def test_is_collection_type_returns(annotation: typing.Any, expected: bool):
+ assert is_collection_type(annotation) is expected
| [BUG] Declaring path param as any kind of instance crashes (at `signature.details.is_collection_type`)
Declaring a path with parameters from e.g. `typing.NewType` raises a `TypingError` from `issubclass`. See relevant traceback below.
```
File "/app/venv/lib/python3.10/site-packages/ninja/router.py", line 238, in decorator
self.add_api_operation(
File "/app/venv/lib/python3.10/site-packages/ninja/router.py", line 285, in add_api_operation
path_view.add_operation(
File "/app/venv/lib/python3.10/site-packages/ninja/operation.py", line 289, in add_operation
operation = OperationClass(
File "/app/venv/lib/python3.10/site-packages/ninja/operation.py", line 240, in __init__
super().__init__(*args, **kwargs)
File "/app/venv/lib/python3.10/site-packages/ninja/operation.py", line 65, in __init__
self.signature = ViewSignature(self.path, self.view_func)
File "/app/venv/lib/python3.10/site-packages/ninja/signature/details.py", line 57, in __init__
func_param = self._get_param_type(name, arg)
File "/app/venv/lib/python3.10/site-packages/ninja/signature/details.py", line 202, in _get_param_type
is_collection = is_collection_type(annotation)
File "/app/venv/lib/python3.10/site-packages/ninja/signature/details.py", line 255, in is_collection_type
return issubclass(annotation, types)
File "/usr/local/lib/python3.10/typing.py", line 1157, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
```
For background, I'm trying to use a custom Django path converter. Which feeds a complex type (based on `pydantic.BaseModel`) that has attributes typed via `typing.NewType`.
In any case, here's a minimal repro:
```python
from typing import NewType
from django.http import HttpRequest, HttpResponse
from ninja import NinjaAPI
Custom = NewType("Custom", str)
api = NinjaAPI()
@api.get("/endpoint/{custom:value}/")
def endpoint(request: HttpRequest, value: Custom) -> HttpResponse:
...
```
**Versions:**
- Python version: `3.10.4`
- Django version: `4.0.4`
- Django-Ninja version: `0.17.0`
| 0.0 | 99281903cfd4db19fd462e875d87e6edace038fc | [
"tests/test_signature_details.py::test_is_collection_type_returns[false_for_custom_instance_without_typing_origin]",
"tests/test_signature_details.py::test_is_collection_type_returns[false_for_instance_without_typing_origin]"
]
| [
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_typing_List]",
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_native_list]",
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_typing_Set]",
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_native_set]",
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_typing_Tuple]",
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_native_tuple]",
"tests/test_signature_details.py::test_is_collection_type_returns[false_for_custom_type_without_typing_origin]",
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_parameterized_native_list]",
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_parameterized_native_set]",
"tests/test_signature_details.py::test_is_collection_type_returns[true_for_parameterized_native_tuple]"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2022-05-03 09:55:46+00:00 | mit | 6,208 |
|
vitalik__django-ninja-667 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index d9e7ff5..5374fc6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -12,7 +12,7 @@ repos:
additional_dependencies: ["django-stubs", "pydantic"]
exclude: (tests|docs)/
- repo: https://github.com/psf/black
- rev: "22.3.0"
+ rev: "23.1.0"
hooks:
- id: black
exclude: docs/src/
diff --git a/ninja/main.py b/ninja/main.py
index fe70c1f..15ce90b 100644
--- a/ninja/main.py
+++ b/ninja/main.py
@@ -353,7 +353,7 @@ class NinjaAPI:
prefix = normalize_path("/".join((parent_prefix, prefix))).lstrip("/")
self._routers.extend(router.build_routers(prefix))
- router.set_api_instance(self)
+ router.set_api_instance(self, parent_router)
@property
def urls(self) -> Tuple[List[Union[URLResolver, URLPattern]], str, str]:
diff --git a/ninja/openapi/schema.py b/ninja/openapi/schema.py
index 022b51d..ce17241 100644
--- a/ninja/openapi/schema.py
+++ b/ninja/openapi/schema.py
@@ -179,7 +179,6 @@ class OpenAPISchema(dict):
by_alias: bool = True,
remove_level: bool = True,
) -> Tuple[DictStrAny, bool]:
-
if hasattr(model, "_flatten_map"):
schema = self._flatten_schema(model)
else:
@@ -242,7 +241,6 @@ class OpenAPISchema(dict):
result = {}
for status, model in operation.response_models.items():
-
if status == Ellipsis:
continue # it's not yet clear what it means if user wants to output any other code
diff --git a/ninja/params_models.py b/ninja/params_models.py
index 3c928fc..3714a87 100644
--- a/ninja/params_models.py
+++ b/ninja/params_models.py
@@ -163,7 +163,6 @@ class FileModel(ParamModel):
class _HttpRequest(HttpRequest):
-
body: bytes = b""
diff --git a/ninja/router.py b/ninja/router.py
index 2bfaa11..53bdec3 100644
--- a/ninja/router.py
+++ b/ninja/router.py
@@ -299,6 +299,8 @@ class Router:
self, api: "NinjaAPI", parent_router: Optional["Router"] = None
) -> None:
# TODO: check - parent_router seems not used
+ if self.auth is NOT_SET and parent_router and parent_router.auth:
+ self.auth = parent_router.auth
self.api = api
for path_view in self.path_operations.values():
path_view.set_api_instance(self.api, self)
diff --git a/ninja/security/http.py b/ninja/security/http.py
index 8deb1c4..6a67296 100644
--- a/ninja/security/http.py
+++ b/ninja/security/http.py
@@ -83,5 +83,7 @@ class HttpBasicAuth(HttpAuthBase, ABC): # TODO: maybe HttpBasicAuthBase
try:
username, password = b64decode(user_pass_encoded).decode().split(":", 1)
return unquote(username), unquote(password)
- except Exception as e: # dear contributors please do not change to valueerror - here can be multiple exceptions
+ except (
+ Exception
+ ) as e: # dear contributors please do not change to valueerror - here can be multiple exceptions
raise DecodeError("Invalid Authorization header") from e
| vitalik/django-ninja | 15d2401a3d926d07e0d817e8af8c9fb1846241e5 | diff --git a/tests/test_auth_inheritance_routers.py b/tests/test_auth_inheritance_routers.py
new file mode 100644
index 0000000..7457026
--- /dev/null
+++ b/tests/test_auth_inheritance_routers.py
@@ -0,0 +1,76 @@
+import pytest
+
+from ninja import NinjaAPI, Router
+from ninja.security import APIKeyQuery
+from ninja.testing import TestClient
+
+
+class Auth(APIKeyQuery):
+ def __init__(self, secret):
+ self.secret = secret
+ super().__init__()
+
+ def authenticate(self, request, key):
+ if key == self.secret:
+ return key
+
+
+api = NinjaAPI()
+
+r1 = Router()
+r2 = Router()
+r3 = Router()
+r4 = Router()
+
+api.add_router("/r1", r1, auth=Auth("r1_auth"))
+r1.add_router("/r2", r2)
+r2.add_router("/r3", r3)
+r3.add_router("/r4", r4, auth=Auth("r4_auth"))
+
+client = TestClient(api)
+
+
[email protected]("/")
+def op1(request):
+ return request.auth
+
+
[email protected]("/")
+def op2(request):
+ return request.auth
+
+
[email protected]("/")
+def op3(request):
+ return request.auth
+
+
[email protected]("/")
+def op4(request):
+ return request.auth
+
+
[email protected]("/op5", auth=Auth("op5_auth"))
+def op5(request):
+ return request.auth
+
+
[email protected](
+ "route, status_code",
+ [
+ ("/r1/", 401),
+ ("/r1/r2/", 401),
+ ("/r1/r2/r3/", 401),
+ ("/r1/r2/r3/r4/", 401),
+ ("/r1/r2/r3/op5", 401),
+ ("/r1/?key=r1_auth", 200),
+ ("/r1/r2/?key=r1_auth", 200),
+ ("/r1/r2/r3/?key=r1_auth", 200),
+ ("/r1/r2/r3/r4/?key=r4_auth", 200),
+ ("/r1/r2/r3/op5?key=op5_auth", 200),
+ ("/r1/r2/r3/r4/?key=r1_auth", 401),
+ ("/r1/r2/r3/op5?key=r1_auth", 401),
+ ],
+)
+def test_router_inheritance_auth(route, status_code):
+ assert client.get(route).status_code == status_code
diff --git a/tests/test_docs/test_body.py b/tests/test_docs/test_body.py
index c259424..a83ca3c 100644
--- a/tests/test_docs/test_body.py
+++ b/tests/test_docs/test_body.py
@@ -5,7 +5,6 @@ from ninja.testing import TestClient
def test_examples():
-
api = NinjaAPI()
with patch("builtins.api", api, create=True):
diff --git a/tests/test_docs/test_form.py b/tests/test_docs/test_form.py
index 0bc3597..315e0f2 100644
--- a/tests/test_docs/test_form.py
+++ b/tests/test_docs/test_form.py
@@ -5,7 +5,6 @@ from ninja.testing import TestClient
def test_examples():
-
api = NinjaAPI()
with patch("builtins.api", api, create=True):
diff --git a/tests/test_docs/test_path.py b/tests/test_docs/test_path.py
index fbd7cb1..1adba45 100644
--- a/tests/test_docs/test_path.py
+++ b/tests/test_docs/test_path.py
@@ -5,7 +5,6 @@ from ninja.testing import TestClient
def test_examples():
-
api = NinjaAPI()
with patch("builtins.api", api, create=True):
diff --git a/tests/test_docs/test_query.py b/tests/test_docs/test_query.py
index a4df178..a94b022 100644
--- a/tests/test_docs/test_query.py
+++ b/tests/test_docs/test_query.py
@@ -5,7 +5,6 @@ from ninja.testing import TestClient
def test_examples():
-
api = NinjaAPI()
with patch("builtins.api", api, create=True):
diff --git a/tests/test_export_openapi_schema.py b/tests/test_export_openapi_schema.py
index bf9fd96..0555e79 100644
--- a/tests/test_export_openapi_schema.py
+++ b/tests/test_export_openapi_schema.py
@@ -11,7 +11,6 @@ from ninja.management.commands.export_openapi_schema import Command as ExportCmd
def test_export_default():
-
output = StringIO()
call_command(ExportCmd(), stdout=output)
json.loads(output.getvalue()) # if no exception, then OK
diff --git a/tests/test_openapi_schema.py b/tests/test_openapi_schema.py
index b5507be..f0e6ab7 100644
--- a/tests/test_openapi_schema.py
+++ b/tests/test_openapi_schema.py
@@ -660,7 +660,6 @@ def test_union_payload_simple(schema):
def test_get_openapi_urls():
-
api = NinjaAPI(openapi_url=None)
paths = get_openapi_urls(api)
assert len(paths) == 0
@@ -677,7 +676,6 @@ def test_get_openapi_urls():
def test_unique_operation_ids():
-
api = NinjaAPI()
@api.get("/1")
diff --git a/tests/test_test_client.py b/tests/test_test_client.py
index c0114f9..f95080e 100644
--- a/tests/test_test_client.py
+++ b/tests/test_test_client.py
@@ -67,7 +67,6 @@ def test_django_2_2_plus_headers(version, has_headers):
class ClientTestSchema(Schema):
-
time: datetime
| Router does not support auth inheritance
**Describe the bug**
When you try adding a new router to an existing router, the leaf router doesn't inherit the top-level auth.
Consider the below example:
```py
from ninja import NinjaAPI, Router
from ninja.security import APIKeyQuery
api = NinjaAPI()
r1 = Router()
r2 = Router()
r3 = Router()
class Auth(APIKeyQuery):
def __init__(self, secret):
self.secret = secret
super().__init__()
def authenticate(self, request, key):
if key == self.secret:
return key
api.add_router("/r1", r1, auth=Auth("r1_auth"))
r1.add_router("/r2", r2)
r2.add_router("/r3", r3)
@r1.get("/")
def op1(request):
return request.auth
@r2.get("/")
def op2(request):
return request.auth
@r3.get("/")
def op3(request):
return request.auth
```
So the auth provided for router `r1` won't be present for any operations in routers `r2` and `r3` even though it comes under it.
This is only for routers though. If we add auth when we initialize `NinjaApi()` it propagates down to all routers and endpoints even if we provide the auth when initializing router r1 as `r1 = Router(auth=Auth("r1_auth"))`. Screenshot of the above code is shown below.
<img width="1453" alt="Screen Shot 2023-01-28 at 9 44 00 AM" src="https://user-images.githubusercontent.com/38973423/215273256-f2b43a14-153a-4e5b-9111-2aa779fc6a0c.png">
I think it's super helpful to include this in the documentation if we don't plan to support it as a dev can easily misinterpret it and in turn, pose a security threat to the app they are building.
**Versions (please complete the following information):**
- Python version: 3.9.12
- Django version: 4.1.5
- Django-Ninja version: 0.20.0
- Pydantic version: 1.10.4
| 0.0 | 15d2401a3d926d07e0d817e8af8c9fb1846241e5 | [
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/-401]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/r3/-401]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/?key=r1_auth-200]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/r3/?key=r1_auth-200]"
]
| [
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/-401]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/r3/r4/-401]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/r3/op5-401]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/?key=r1_auth-200]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/r3/r4/?key=r4_auth-200]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/r3/op5?key=op5_auth-200]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/r3/r4/?key=r1_auth-401]",
"tests/test_auth_inheritance_routers.py::test_router_inheritance_auth[/r1/r2/r3/op5?key=r1_auth-401]",
"tests/test_docs/test_body.py::test_examples",
"tests/test_docs/test_form.py::test_examples",
"tests/test_docs/test_path.py::test_examples",
"tests/test_docs/test_query.py::test_examples",
"tests/test_export_openapi_schema.py::test_export_default",
"tests/test_export_openapi_schema.py::test_export_indent",
"tests/test_export_openapi_schema.py::test_export_to_file",
"tests/test_export_openapi_schema.py::test_export_custom",
"tests/test_openapi_schema.py::test_schema_views",
"tests/test_openapi_schema.py::test_schema_views_no_INSTALLED_APPS",
"tests/test_openapi_schema.py::test_schema",
"tests/test_openapi_schema.py::test_schema_alias",
"tests/test_openapi_schema.py::test_schema_list",
"tests/test_openapi_schema.py::test_schema_body",
"tests/test_openapi_schema.py::test_schema_body_schema",
"tests/test_openapi_schema.py::test_schema_path",
"tests/test_openapi_schema.py::test_schema_form",
"tests/test_openapi_schema.py::test_schema_single",
"tests/test_openapi_schema.py::test_schema_form_body",
"tests/test_openapi_schema.py::test_schema_form_file",
"tests/test_openapi_schema.py::test_schema_body_file",
"tests/test_openapi_schema.py::test_schema_title_description",
"tests/test_openapi_schema.py::test_union_payload_type",
"tests/test_openapi_schema.py::test_union_payload_simple",
"tests/test_openapi_schema.py::test_get_openapi_urls",
"tests/test_openapi_schema.py::test_unique_operation_ids",
"tests/test_openapi_schema.py::test_docs_decorator",
"tests/test_openapi_schema.py::test_renderer_media_type",
"tests/test_test_client.py::test_sync_build_absolute_uri[/request/build_absolute_uri-HTTPStatus.OK-http:/testlocation/]",
"tests/test_test_client.py::test_sync_build_absolute_uri[/request/build_absolute_uri/location-HTTPStatus.OK-http:/testlocation/location]",
"tests/test_test_client.py::test_django_2_2_plus_headers[version0-False]",
"tests/test_test_client.py::test_django_2_2_plus_headers[version1-False]",
"tests/test_test_client.py::test_django_2_2_plus_headers[version2-True]",
"tests/test_test_client.py::test_django_2_2_plus_headers[version3-True]",
"tests/test_test_client.py::test_schema_as_data",
"tests/test_test_client.py::test_json_as_body"
]
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_media",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-01-28 15:07:37+00:00 | mit | 6,209 |
|
vitalik__django-ninja-838 | diff --git a/ninja/errors.py b/ninja/errors.py
index 1be1dff..3c1056a 100644
--- a/ninja/errors.py
+++ b/ninja/errors.py
@@ -39,14 +39,18 @@ class ValidationError(Exception):
"""
def __init__(self, errors: List[DictStrAny]) -> None:
- super().__init__()
self.errors = errors
+ super().__init__(errors)
class HttpError(Exception):
def __init__(self, status_code: int, message: str) -> None:
self.status_code = status_code
- super().__init__(message)
+ self.message = message
+ super().__init__(status_code, message)
+
+ def __str__(self) -> str:
+ return self.message
def set_default_exc_handlers(api: "NinjaAPI") -> None:
| vitalik/django-ninja | 8be35e42a9dc2365e764a0fea0a0b868eeae312b | diff --git a/tests/test_errors.py b/tests/test_errors.py
new file mode 100644
index 0000000..b19c015
--- /dev/null
+++ b/tests/test_errors.py
@@ -0,0 +1,26 @@
+import pickle
+
+from ninja.errors import HttpError, ValidationError
+
+
+def test_validation_error_is_picklable_and_unpicklable():
+ error_to_serialize = ValidationError([{"testkey": "testvalue"}])
+
+ serialized = pickle.dumps(error_to_serialize)
+ assert serialized # Not empty
+
+ deserialized = pickle.loads(serialized)
+ assert isinstance(deserialized, ValidationError)
+ assert deserialized.errors == error_to_serialize.errors
+
+
+def test_http_error_is_picklable_and_unpicklable():
+ error_to_serialize = HttpError(500, "Test error")
+
+ serialized = pickle.dumps(error_to_serialize)
+ assert serialized # Not empty
+
+ deserialized = pickle.loads(serialized)
+ assert isinstance(deserialized, HttpError)
+ assert deserialized.status_code == error_to_serialize.status_code
+ assert deserialized.message == error_to_serialize.message
| [BUG] "ValidationError" and "HttpError" are not unpickable
**Describe the bug**
Hi.
It seems the `ValidationError` can be pickled but not un-pickled:
```python
import pickle
from ninja.errors import ValidationError
error = ValidationError(errors=[])
serialized = pickle.dumps(error) # OK
deserialized = pickle.loads(serialized) # NOK
```
It causes:
```
Traceback (most recent call last):
File "/home/delgan/test.py", line 6, in <module>
deserialized = pickle.loads(serialized)
^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ValidationError.__init__() missing 1 required positional argument: 'errors'
```
This is actually a reccurent problem while inheriting Python `Exception`:
- [Cannot unpickle Exception subclass](https://stackoverflow.com/questions/41808912/cannot-unpickle-exception-subclass)
- [How to pickle inherited exceptions?](https://stackoverflow.com/questions/49715881/how-to-pickle-inherited-exceptions)
- [How to make a custom exception class with multiple init args pickleable](https://stackoverflow.com/questions/16244923/how-to-make-a-custom-exception-class-with-multiple-init-args-pickleable)
The fix requires to implement a `__reduce__` method for these classes.
The `multiprocessing` module makes extensive use of `pickle` protocol, and having objects that can't be de-serialized is source of unexpected errors (in my case, because the `Exception` is sent to a background processing thread for logging).
**Versions (please complete the following information):**
- Python version: 3.11.3
- Django version: 4.2.4
- Django-Ninja version: 0.22.2
- Pydantic version: 0.4.4
| 0.0 | 8be35e42a9dc2365e764a0fea0a0b868eeae312b | [
"tests/test_errors.py::test_validation_error_is_picklable_and_unpicklable",
"tests/test_errors.py::test_http_error_is_picklable_and_unpicklable"
]
| []
| {
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-08-30 18:30:44+00:00 | mit | 6,210 |
|
vivisect__vivisect-447 | diff --git a/envi/archs/i386/emu.py b/envi/archs/i386/emu.py
index 658a6f7..02e9b6a 100755
--- a/envi/archs/i386/emu.py
+++ b/envi/archs/i386/emu.py
@@ -9,7 +9,7 @@ from envi.const import *
import envi.exc as e_exc
import envi.bits as e_bits
-from envi.archs.i386.opconst import PREFIX_REX_W
+from envi.archs.i386.opconst import PREFIX_REX_W, REP_OPCODES
from envi.archs.i386.regs import *
from envi.archs.i386.disasm import *
from envi.archs.i386 import i386Module
@@ -245,8 +245,9 @@ class IntelEmulator(i386RegisterContext, envi.Emulator):
if meth is None:
raise e_exc.UnsupportedInstruction(self, op)
+ # The behavior of the REP prefix is undefined when used with non-string instructions.
rep_prefix = op.prefixes & PREFIX_REP_MASK
- if rep_prefix and not self.getEmuOpt('i386:reponce'):
+ if rep_prefix and op.opcode in REP_OPCODES and not self.getEmuOpt('i386:reponce'):
# REP instructions (REP/REPNZ/REPZ/REPSIMD) get their own handlers
handler = self.__rep_prefix_handlers__.get(rep_prefix)
newpc = handler(meth, op)
@@ -273,9 +274,6 @@ class IntelEmulator(i386RegisterContext, envi.Emulator):
Then the instruction is repeated and ECX decremented until either
ECX reaches 0 or the ZF is cleared.
'''
- if op.mnem.startswith('nop'):
- return
-
ecx = emu.getRegister(REG_ECX)
emu.setFlag(EFLAGS_ZF, 1)
diff --git a/envi/archs/i386/opconst.py b/envi/archs/i386/opconst.py
index 9fc2db9..4f9add5 100644
--- a/envi/archs/i386/opconst.py
+++ b/envi/archs/i386/opconst.py
@@ -197,15 +197,24 @@ INS_OFLOW = INS_TRAPS | 0x08 # gen overflow trap
#/* INS_SYSTEM */
INS_HALT = INS_SYSTEM | 0x01 # halt machine
-INS_IN = INS_SYSTEM | 0x02 # input form port
+INS_IN = INS_SYSTEM | 0x02 # input from port
INS_OUT = INS_SYSTEM | 0x03 # output to port
INS_CPUID = INS_SYSTEM | 0x04 # iden
INS_NOP = INS_OTHER | 0x01
INS_BCDCONV = INS_OTHER | 0x02 # convert to/from BCD
INS_SZCONV = INS_OTHER | 0x03 # convert size of operand
-INS_CRYPT = INS_OTHER | 0x4 # AES-NI instruction support
+INS_CRYPT = INS_OTHER | 0x04 # AES-NI instruction support
+# string instructions that support REP prefix
+REP_OPCODES = (
+ INS_IN, # INS
+ INS_OUT, # OUTS
+ INS_STRMOV, # MOVS
+ INS_STRLOAD, # LODS
+ INS_STRSTOR, # STOS
+ INS_STRCMP # CMPS, SCAS
+ )
OP_R = 0x001
OP_W = 0x002
| vivisect/vivisect | e1f86b698704f37bebbe3996c7138d871c00652f | diff --git a/envi/tests/test_arch_i386_emu.py b/envi/tests/test_arch_i386_emu.py
index 273a29d..d8b26e7 100644
--- a/envi/tests/test_arch_i386_emu.py
+++ b/envi/tests/test_arch_i386_emu.py
@@ -108,7 +108,12 @@ i386Tests = [
# lea ecx,dword [esp + -973695896] (test SIB getOperAddr)
{'bytes': '8d8c246894f6c5',
'setup': ({'esp': 0x7fd0}, {}),
- 'tests': ({'ecx': 0xc5f71438}, {})}
+ 'tests': ({'ecx': 0xc5f71438}, {})},
+ # rep ret
+ # The behavior of the REP prefix is undefined when used with non-string instructions.
+ {'bytes': 'f3c3',
+ 'setup': ({'ecx': 0x1}, {'esp': b'\x00\x00\x00\x60'}),
+ 'tests': ({'ecx': 0x1, 'eip': 0x60000000}, {})}
]
| i386 rep emulation incorrect
The current emulator runs the rep prefix for every instruction.
Per the Intel manual: "The behavior of the REP prefix is undefined when used with non-string instructions."
Example assembly resulting in incorrect / slow emulation decrementing undefined `ecx` value.
```asm
.text:00402107 74 07 jz short loc_402110
.text:00402109 F3 C3 rep retn
```
References:
- https://repzret.org/p/repzret/
- https://stackoverflow.com/questions/10258918/what-happens-when-a-rep-prefix-is-attached-to-a-non-string-instruction | 0.0 | e1f86b698704f37bebbe3996c7138d871c00652f | [
"envi/tests/test_arch_i386_emu.py::i386EmulatorTests::test_i386_emulator"
]
| [
"envi/tests/test_arch_i386_emu.py::i386EmulatorTests::test_i386_reps",
"envi/tests/test_arch_i386_emu.py::i386EmulatorTests::test_x86_OperAddrs"
]
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-08-30 12:15:50+00:00 | apache-2.0 | 6,211 |
|
vogt4nick__dequindre-53 | diff --git a/.bumpversion.cfg b/.bumpversion.cfg
index a13f5ef..b6ca05f 100644
--- a/.bumpversion.cfg
+++ b/.bumpversion.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 0.5.0.dev0
+current_version = 0.5.0.dev1
commit = True
tag = False
parse = (?P<major>\d+)
diff --git a/dequindre/__init__.py b/dequindre/__init__.py
index ad99842..b8e0a67 100644
--- a/dequindre/__init__.py
+++ b/dequindre/__init__.py
@@ -16,7 +16,7 @@ from subprocess import check_output, CalledProcessError
from time import sleep
-__version__ = '0.5.0.dev0'
+__version__ = '0.5.0.dev1'
class CyclicGraphError(Exception):
@@ -360,8 +360,8 @@ class Dequindre:
return None
- def get_task_priorities(self) -> Dict[Task, int]:
- """Define priority level for each task
+ def get_task_schedules(self) -> Dict[Task, int]:
+ """Define schedule priority level for each task
Example:
make_tea -> pour_tea -> drink_tea will give the dict
@@ -388,8 +388,8 @@ class Dequindre:
return task_priority
- def get_priorities(self) -> Dict[int, Set[Task]]:
- """Define tasks for each priority level.
+ def get_schedules(self) -> Dict[int, Set[Task]]:
+ """Schedule tasks by priority level.
Example:
make_tea -> pour_tea -> drink_tea will give the dict
@@ -400,7 +400,7 @@ class Dequindre:
}
"""
priorities = defaultdict(set)
- task_priorities = self.get_task_priorities()
+ task_priorities = self.get_task_schedules()
for k, v in task_priorities.items():
priorities[v].add(k)
@@ -425,7 +425,7 @@ class Dequindre:
def run_tasks(self):
"""Run all tasks on the DAG"""
self.refresh_dag() # refresh just in case
- priorities = self.get_priorities()
+ priorities = self.get_schedules()
for k, tasks in priorities.items():
for task in tasks:
diff --git a/readme.md b/readme.md
index 6215e39..1e03959 100644
--- a/readme.md
+++ b/readme.md
@@ -37,7 +37,7 @@ Dequindre allows dynamic configuration with Python. By example, we may program t
>>>
>>> # run tasks
>>> dq = Dequindre(dag, check_conda=False)
->>> dq = dq.get_priorities()
+>>> dq = dq.get_schedules()
defaultdict(<class 'set'>, {
1: {Task(make_tea.py), Task(prep_infuser.py)},
2: {Task(boil_water.py)},
| vogt4nick/dequindre | 40465f0af55515c359f5e9965f38480df700149e | diff --git a/dequindre/tests/test_Dequindre.py b/dequindre/tests/test_Dequindre.py
index a48eb58..82b8b1c 100644
--- a/dequindre/tests/test_Dequindre.py
+++ b/dequindre/tests/test_Dequindre.py
@@ -68,7 +68,7 @@ def test__Dequindre_refresh_dag():
assert t == nt
-def test__Dequindre_get_task_priorities():
+def test__Dequindre_get_task_schedules():
A = Task('A.py', 'test-env')
B = Task('B.py', 'test-env')
C = Task('C.py', 'test-env')
@@ -78,7 +78,7 @@ def test__Dequindre_get_task_priorities():
dag.add_edges({A:B, B:C})
dq = Dequindre(dag)
- priorities = dq.get_task_priorities()
+ priorities = dq.get_task_schedules()
testable = {hash(k): v for k, v in priorities.items()}
assert testable == {
@@ -89,7 +89,7 @@ def test__Dequindre_get_task_priorities():
}
-def test__Dequindre_get_priorities():
+def test__Dequindre_get_schedules():
A = Task('A.py', 'test-env')
B = Task('B.py', 'test-env')
C = Task('C.py', 'test-env')
@@ -99,7 +99,7 @@ def test__Dequindre_get_priorities():
dag.add_edges({A:B, B:C})
dq = Dequindre(dag)
- priorities = dq.get_priorities()
+ priorities = dq.get_schedules()
testable = {}
# build a testable result dict
| Rework schedule methods
`Dequindre.get_task_priorities` and `Dequindre.get_priorities` is a little opaque.
### Proposal A
We rename `get_task_priorities` to `get_task_schedules`, and rename `get_priorities` to `get_schedules`. They'll return the same values, but the new names will be more obvious to users.
### Proposal B
We keep `get_task_priorities` and `get_priorities` as they are. We introduce `get_schedules` which returns an ordered list of when the tasks will be run at runtime.
Proposal A sounds best right now, but we should stew on it a bit before making a final decision. | 0.0 | 40465f0af55515c359f5e9965f38480df700149e | [
"dequindre/tests/test_Dequindre.py::test__Dequindre_get_task_schedules",
"dequindre/tests/test_Dequindre.py::test__Dequindre_get_schedules"
]
| [
"dequindre/tests/test_Dequindre.py::test__Dequindre_init_exceptions",
"dequindre/tests/test_Dequindre.py::test__Dequindre_init",
"dequindre/tests/test_Dequindre.py::test__Dequindre_repr",
"dequindre/tests/test_Dequindre.py::test__Dequindre_refresh_dag"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2019-02-24 15:37:49+00:00 | mit | 6,212 |
|
vprusso__toqito-26 | diff --git a/docs/channels.rst b/docs/channels.rst
index f0a73b7..22cc7f0 100644
--- a/docs/channels.rst
+++ b/docs/channels.rst
@@ -64,3 +64,4 @@ Properties of Quantum Channels
toqito.channel_props.is_herm_preserving
toqito.channel_props.is_positive
toqito.channel_props.is_unital
+ toqito.channel_props.choi_rank
diff --git a/toqito/channel_props/__init__.py b/toqito/channel_props/__init__.py
index 74eab7f..66750f4 100644
--- a/toqito/channel_props/__init__.py
+++ b/toqito/channel_props/__init__.py
@@ -3,3 +3,4 @@ from toqito.channel_props.is_herm_preserving import is_herm_preserving
from toqito.channel_props.is_completely_positive import is_completely_positive
from toqito.channel_props.is_positive import is_positive
from toqito.channel_props.is_unital import is_unital
+from toqito.channel_props.choi_rank import choi_rank
diff --git a/toqito/channel_props/choi_rank.py b/toqito/channel_props/choi_rank.py
new file mode 100644
index 0000000..dcc6b18
--- /dev/null
+++ b/toqito/channel_props/choi_rank.py
@@ -0,0 +1,89 @@
+"""Calculate the Choi rank of a channel."""
+from typing import List, Union
+
+import numpy as np
+from toqito.channel_ops import kraus_to_choi
+
+
+def choi_rank(phi: Union[np.ndarray, List[List[np.ndarray]]]) -> int:
+ r"""
+ Calculate the rank of the Choi representation of a quantum channel.
+
+ Examples
+ ==========
+
+ The transpose map can be written either in Choi representation (as a
+ SWAP operator) or in Kraus representation. If we choose the latter, it
+ will be given by the following matrices:
+
+ .. math::
+ \begin{equation}
+ \begin{aligned}
+ \frac{1}{\sqrt{2}}
+ \begin{pmatrix}
+ 0 & i \\ -i & 0
+ \end{pmatrix}, &\quad
+ \frac{1}{\sqrt{2}}
+ \begin{pmatrix}
+ 0 & 1 \\
+ 1 & 0
+ \end{pmatrix}, \\
+ \begin{pmatrix}
+ 1 & 0 \\
+ 0 & 0
+ \end{pmatrix}, &\quad
+ \begin{pmatrix}
+ 0 & 0 \\
+ 0 & 1
+ \end{pmatrix}.
+ \end{aligned}
+ \end{equation}
+
+ and can be generated in :code:`toqito` with the following list:
+
+ >>> import numpy as np
+ >>> kraus_1 = np.array([[1, 0], [0, 0]])
+ >>> kraus_2 = np.array([[1, 0], [0, 0]]).conj().T
+ >>> kraus_3 = np.array([[0, 1], [0, 0]])
+ >>> kraus_4 = np.array([[0, 1], [0, 0]]).conj().T
+ >>> kraus_5 = np.array([[0, 0], [1, 0]])
+ >>> kraus_6 = np.array([[0, 0], [1, 0]]).conj().T
+ >>> kraus_7 = np.array([[0, 0], [0, 1]])
+ >>> kraus_8 = np.array([[0, 0], [0, 1]]).conj().T
+ >>> kraus_ops = [
+ >>> [kraus_1, kraus_2],
+ >>> [kraus_3, kraus_4],
+ >>> [kraus_5, kraus_6],
+ >>> [kraus_7, kraus_8],
+ >>> ]
+
+ To calculate its Choi rank, we proceed in the following way:
+
+ >>> from toqito.channel_props import choi_rank
+ >>> choi_rank(kraus_ops)
+ 4
+
+ We can the verify the associated Choi representation (the SWAP gate)
+ gets the same Choi rank:
+
+ >>> choi_matrix = np.array([[1,0,0,0],[0,0,1,0],[0,1,0,0],[0,0,0,1]])
+ >>> choi_rank(choi_matrix)
+ 4
+
+ References
+ ==========
+
+ .. [WatDepo18] Watrous, John.
+ "The theory of quantum information."
+ Section: "2.2 Quantum Channels".
+ Cambridge University Press, 2018.
+
+ :param phi: Either a Choi matrix or a list of Kraus operators
+ :return: The Choi rank of the provided channel representation.
+ """
+ if isinstance(phi, list):
+ phi = kraus_to_choi(phi)
+ elif not isinstance(phi, np.ndarray):
+ raise ValueError("Not a valid Choi matrix.")
+
+ return np.linalg.matrix_rank(phi)
| vprusso/toqito | 530682340a703952061a520612468d5142efd7ca | diff --git a/tests/test_channel_props/test_choi_rank.py b/tests/test_channel_props/test_choi_rank.py
new file mode 100644
index 0000000..f6dddef
--- /dev/null
+++ b/tests/test_channel_props/test_choi_rank.py
@@ -0,0 +1,44 @@
+"""Tests for choi_rank."""
+import numpy as np
+import pytest
+
+from toqito.channel_props import choi_rank
+
+
+def test_choi_rank_list_kraus():
+ """Verify that a list of Kraus operators gives correct Choi rank"""
+ kraus_1 = np.array([[1, 0], [0, 0]])
+ kraus_2 = np.array([[1, 0], [0, 0]]).conj().T
+ kraus_3 = np.array([[0, 1], [0, 0]])
+ kraus_4 = np.array([[0, 1], [0, 0]]).conj().T
+ kraus_5 = np.array([[0, 0], [1, 0]])
+ kraus_6 = np.array([[0, 0], [1, 0]]).conj().T
+ kraus_7 = np.array([[0, 0], [0, 1]])
+ kraus_8 = np.array([[0, 0], [0, 1]]).conj().T
+
+ kraus_ops = [
+ [kraus_1, kraus_2],
+ [kraus_3, kraus_4],
+ [kraus_5, kraus_6],
+ [kraus_7, kraus_8],
+ ]
+ np.testing.assert_equal(choi_rank(kraus_ops), 4)
+
+
+def test_choi_rank_choi_matrix():
+ """Verify Choi matrix of the swap operator map gives correct Choi rank."""
+ choi_matrix = np.array([[1, 0, 0, 0], [0, 0, 1, 0],
+ [0, 1, 0, 0], [0, 0, 0, 1]])
+ np.testing.assert_equal(choi_rank(choi_matrix), 4)
+
+
+def test_choi_bad_input():
+ """Verify that a bad input (such as a string which still passes
+ with `numpy.linalg.matrix_rank`) raises an error"""
+ with pytest.raises(ValueError, match="Not a valid"):
+ bad_input = 'string'
+ choi_rank(bad_input)
+
+
+if __name__ == "__main__":
+ np.testing.run_module_suite()
| Feature: Choi rank
Write a function that calculates the "Choi rank".
Refer to page 79 of https://cs.uwaterloo.ca/~watrous/TQI/TQI.pdf for the definition of the Choi rank.
In short, the Choi rank is the rank of the Choi representation of a quantum channel. The input to the function should be either a set of Kraus operators or a Choi matrix. If the former, the Kraus operators should be converted to a Choi matrix. Calculating the matrix rank of the resulting Choi matrix would yield the desired "Choi rank".
This task would also require adding test coverage for the function along with ensuring it is included in the docs. Refer to the style guide and code contributing guidelines for more information. | 0.0 | 530682340a703952061a520612468d5142efd7ca | [
"tests/test_channel_props/test_choi_rank.py::test_choi_rank_list_kraus",
"tests/test_channel_props/test_choi_rank.py::test_choi_rank_choi_matrix",
"tests/test_channel_props/test_choi_rank.py::test_choi_bad_input"
]
| []
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_added_files",
"has_many_modified_files",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false
} | 2021-01-28 13:06:44+00:00 | mit | 6,213 |
|
vprusso__toqito-27 | diff --git a/docs/_autosummary/toqito.channel_props.is_trace_preserving.rst b/docs/_autosummary/toqito.channel_props.is_trace_preserving.rst
new file mode 100644
index 0000000..cb62066
--- /dev/null
+++ b/docs/_autosummary/toqito.channel_props.is_trace_preserving.rst
@@ -0,0 +1,6 @@
+toqito.channel\_props.is\_trace\_preserving
+==========================================
+
+.. currentmodule:: toqito.channel_props
+
+.. autofunction:: is_trace_preserving
diff --git a/toqito/channel_props/__init__.py b/toqito/channel_props/__init__.py
index 66750f4..c66cdc3 100644
--- a/toqito/channel_props/__init__.py
+++ b/toqito/channel_props/__init__.py
@@ -4,3 +4,4 @@ from toqito.channel_props.is_completely_positive import is_completely_positive
from toqito.channel_props.is_positive import is_positive
from toqito.channel_props.is_unital import is_unital
from toqito.channel_props.choi_rank import choi_rank
+from toqito.channel_props.is_trace_preserving import is_trace_preserving
diff --git a/toqito/channel_props/is_trace_preserving.py b/toqito/channel_props/is_trace_preserving.py
new file mode 100644
index 0000000..19db908
--- /dev/null
+++ b/toqito/channel_props/is_trace_preserving.py
@@ -0,0 +1,104 @@
+"""Is channel trace-preserving."""
+from typing import List, Union
+
+import numpy as np
+
+from toqito.matrix_props import is_identity
+from toqito.channels import partial_trace
+
+
+def is_trace_preserving(
+ phi: Union[np.ndarray, List[List[np.ndarray]]],
+ rtol: float = 1e-05,
+ atol: float = 1e-08,
+ sys: Union[int, List[int]] = 2,
+ dim: Union[List[int], np.ndarray] = None,
+) -> bool:
+ r"""
+ Determine whether the given channel is trace-preserving [WatH18]_.
+
+ A map :math:`\Phi \in \text{T} \left(\mathcal{X}, \mathcal{Y} \right)` is
+ *trace-preserving* if it holds that
+
+ .. math::
+ \text{Tr} \left( \Phi(X) \right) = \text{Tr}\left( X \right)
+
+ for every operator :math:`X \in \text{L}(\mathcal{X})`.
+
+ Given the corresponding Choi matrix of the channel, a neccessary and sufficient condition is
+
+ .. math::
+ \text{Tr}_{\mathcal{Y}} \left( J(\Phi) \right) = \mathbb{I}_{\mathcal{X}}
+
+ In case :code:`sys` is not specified, the default convention is that the Choi matrix
+ is the result of applying the map to the second subsystem of the standard maximally
+ entangled (unnormalized) state.
+
+ The dimensions of the subsystems are given by the vector :code:`dim`. By default,
+ both subsystems have equal dimension.
+
+ Alternatively, given a list of Kraus operators, a neccessary and sufficient condition is
+
+ .. math::
+ \sum_{a \in \Sigma} A_a^* B_a = \mathbb{I}_{\mathcal{X}}
+
+ Examples
+ ==========
+
+ The map :math:`\Phi` defined as
+
+ .. math::
+ \Phi(X) = X - U X U^*
+
+ is not trace-preserving, where
+
+ .. math::
+ U = \frac{1}{\sqrt{2}}
+ \begin{pmatrix}
+ 1 & 1 \\
+ -1 & 1
+ \end{pmatrix}.
+
+ >>> import numpy as np
+ >>> from toqito.channel_props import is_trace_preserving
+ >>> unitary_mat = np.array([[1, 1], [-1, 1]]) / np.sqrt(2)
+ >>> kraus_ops = [[np.identity(2), np.identity(2)], [unitary_mat, -unitary_mat]]
+ >>> is_trace_preserving(kraus_ops)
+ False
+
+ As another example, the depolarizing channel is trace-preserving.
+
+ >>> from toqito.channels import depolarizing
+ >>> from toqito.channel_props import is_trace_preserving
+ >>> choi_mat = depolarizing(2)
+ >>> is_trace_preserving(choi_mat)
+ True
+
+ References
+ ==========
+ .. [WatH18] Watrous, John.
+ "The theory of quantum information."
+ Section: "Linear maps of square operators".
+ Cambridge University Press, 2018.
+
+ :param phi: The channel provided as either a Choi matrix or a list of Kraus operators.
+ :param rtol: The relative tolerance parameter (default 1e-05).
+ :param atol: The absolute tolerance parameter (default 1e-08).
+ :param sys: Scalar or vector specifying the size of the subsystems.
+ :param dim: Dimension of the subsystems. If :code:`None`, all dimensions are assumed to be
+ equal.
+ :return: True if the channel is trace-preserving, and False otherwise.
+ """
+ # If the variable `phi` is provided as a list, we assume this is a list
+ # of Kraus operators.
+ if isinstance(phi, list):
+ phi_l = [A for A, _ in phi]
+ phi_r = [B for _, B in phi]
+
+ k_l = np.concatenate(phi_l, axis=0)
+ k_r = np.concatenate(phi_r, axis=0)
+
+ mat = k_l.conj().T @ k_r
+ else:
+ mat = partial_trace(input_mat=phi, sys=sys, dim=dim)
+ return is_identity(mat, rtol=rtol, atol=atol)
| vprusso/toqito | d9379fb267a8e77784b97820c3131522d384f54d | diff --git a/tests/test_channel_props/test_is_trace_preserving.py b/tests/test_channel_props/test_is_trace_preserving.py
new file mode 100644
index 0000000..de9f2b2
--- /dev/null
+++ b/tests/test_channel_props/test_is_trace_preserving.py
@@ -0,0 +1,22 @@
+"""Tests for is_trace_preserving."""
+import numpy as np
+
+from toqito.channel_props import is_trace_preserving
+from toqito.channels import depolarizing
+
+
+def test_is_trace_preserving_kraus_false():
+ """Verify non-trace preserving channel as Kraus ops as False."""
+ unitary_mat = np.array([[1, 1], [-1, 1]]) / np.sqrt(2)
+ kraus_ops = [[np.identity(2), np.identity(2)], [unitary_mat, -unitary_mat]]
+
+ np.testing.assert_equal(is_trace_preserving(kraus_ops), False)
+
+
+def test_is_trace_preserving_choi_true():
+ """Verify Choi matrix of the depolarizing map is trace preserving."""
+ np.testing.assert_equal(is_trace_preserving(depolarizing(2)), True)
+
+
+if __name__ == "__main__":
+ np.testing.run_module_suite()
| Feature: Is trace preserving
Given a channel specified by either its Choi matrix or its Kraus representation, determine if the channel is trace-preserving.
For the definition of what constitutes a channel to be trace-preserving, refer to Section 2.2.1 of https://cs.uwaterloo.ca/~watrous/TQI/TQI.pdf
This would involve creating `channel_props/is_trace_preserving.py` and adding the logic there. Refer to other files in the same directory, namely `is_completely_positive.py`, `is_herm_preserving.py`, etc. for ensuring consistency amongst the other related functions.
The function prototype would follow this form:
```
def is_trace_preserving(
phi: Union[np.ndarray, List[List[np.ndarray]]],
rtol: float = 1e-05,
atol: float = 1e-08,
) -> bool:
...
```
This task would also require adding test coverage for the function along with ensuring it is included in the docs. Refer to the style guide and code contributing guidelines for more information. | 0.0 | d9379fb267a8e77784b97820c3131522d384f54d | [
"tests/test_channel_props/test_is_trace_preserving.py::test_is_trace_preserving_kraus_false",
"tests/test_channel_props/test_is_trace_preserving.py::test_is_trace_preserving_choi_true"
]
| []
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_added_files"
],
"has_test_patch": true,
"is_lite": false
} | 2021-01-28 13:52:11+00:00 | mit | 6,214 |
|
wagtail__wagtail-10469 | diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 0f001c1f76..f399c22696 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -11,6 +11,7 @@ Changelog
* Add oEmbed provider patterns for YouTube Shorts Shorts and YouTube Live URLs (valnuro, Fabien Le Frapper)
* Add initial implementation of `PagePermissionPolicy` (Sage Abdullah)
* Refactor `UserPagePermissionsProxy` and `PagePermissionTester` to use `PagePermissionPolicy` (Sage Abdullah)
+ * Add a predictable default ordering of the "Object/Other permissions" in the Group Editing view, allow this ordering to be customised (Daniel Kirkham)
* Fix: Prevent choosers from failing when initial value is an unrecognised ID, e.g. when moving a page from a location where `parent_page_types` would disallow it (Dan Braghis)
* Fix: Move comment notifications toggle to the comments side panel (Sage Abdullah)
* Fix: Remove comment button on InlinePanel fields (Sage Abdullah)
diff --git a/docs/extending/customising_group_views.md b/docs/extending/customising_group_views.md
index c3abae4070..3e56d16737 100644
--- a/docs/extending/customising_group_views.md
+++ b/docs/extending/customising_group_views.md
@@ -106,3 +106,29 @@ INSTALLED_APPS = [
...,
]
```
+
+(customising_group_views_permissions_order)=
+
+## Customising the group editor permissions ordering
+
+The order that object types appear in the group editor's "Object permissions" and "Other permissions" sections can be configured by registering that order in one or more `AppConfig` definitions. The order value is typically an integer between 0 and 999, although this is not enforced.
+
+```python
+from django.apps import AppConfig
+
+
+class MyProjectAdminAppConfig(AppConfig):
+ name = "myproject_admin"
+ verbose_name = "My Project Admin"
+
+ def ready(self):
+ from wagtail.users.permission_order import register
+
+ register("gadgets.SprocketType", order=150)
+ register("gadgets.ChainType", order=151)
+ register("site_settings.Settings", order=160)
+```
+
+A model class can also be passed to `register()`.
+
+Any object types that are not explicitly given an order will be sorted in alphabetical order by `app_label` and `model`, and listed after all of the object types _with_ a configured order.
diff --git a/docs/releases/5.1.md b/docs/releases/5.1.md
index a471821509..8f2156a73c 100644
--- a/docs/releases/5.1.md
+++ b/docs/releases/5.1.md
@@ -23,6 +23,7 @@ FieldPanels can now be marked as read-only with the `read_only=True` keyword arg
* Add oEmbed provider patterns for YouTube Shorts (e.g. [https://www.youtube.com/shorts/nX84KctJtG0](https://www.youtube.com/shorts/nX84KctJtG0)) and YouTube Live URLs (valnuro, Fabien Le Frapper)
* Add initial implementation of `PagePermissionPolicy` (Sage Abdullah)
* Refactor `UserPagePermissionsProxy` and `PagePermissionTester` to use `PagePermissionPolicy` (Sage Abdullah)
+ * Add a predictable default ordering of the "Object/Other permissions" in the Group Editing view, allow this [ordering to be customised](customising_group_views_permissions_order) (Daniel Kirkham)
### Bug fixes
@@ -120,3 +121,10 @@ If you use the `user_page_permissions` context variable or use the `UserPagePerm
The undocumented `get_pages_with_direct_explore_permission` and `get_explorable_root_page` functions in `wagtail.admin.navigation` are deprecated. They can be replaced with `PagePermissionPolicy().instances_with_direct_explore_permission(user)` and `PagePermissionPolicy().explorable_root_instance(user)`, respectively.
The undocumented `users_with_page_permission` function in `wagtail.admin.auth` is also deprecated. It can be replaced with `PagePermissionPolicy().users_with_permission_for_instance(action, page, include_superusers)`.
+
+### The default ordering of Group Editing Permissions models has changed
+
+The ordering for "Object permissions" and "Other permissions" now follows a predictable order equivalent do Django's default `Model` ordering.
+This will be different to the previous ordering which never intentionally implemented.
+
+This default ordering is now `["content_type__app_label", "content_type__model", "codename"]`, which can now be customised [](customising_group_views_permissions_order).
diff --git a/wagtail/users/permission_order.py b/wagtail/users/permission_order.py
new file mode 100644
index 0000000000..2314deff3f
--- /dev/null
+++ b/wagtail/users/permission_order.py
@@ -0,0 +1,17 @@
+from django.contrib.contenttypes.models import ContentType
+
+from wagtail.coreutils import resolve_model_string
+
+CONTENT_TYPE_ORDER = {}
+
+
+def register(model, **kwargs):
+ """
+ Registers order against the model content_type, used to
+ control the order the models and its permissions appear
+ in the groups object permission editor
+ """
+ order = kwargs.pop("order", None)
+ if order is not None:
+ content_type = ContentType.objects.get_for_model(resolve_model_string(model))
+ CONTENT_TYPE_ORDER[content_type.id] = order
diff --git a/wagtail/users/templatetags/wagtailusers_tags.py b/wagtail/users/templatetags/wagtailusers_tags.py
index 34b3f411a2..c188425ad0 100644
--- a/wagtail/users/templatetags/wagtailusers_tags.py
+++ b/wagtail/users/templatetags/wagtailusers_tags.py
@@ -4,6 +4,7 @@ import re
from django import template
from wagtail import hooks
+from wagtail.users.permission_order import CONTENT_TYPE_ORDER
register = template.Library()
@@ -38,8 +39,13 @@ def format_permissions(permission_bound_field):
"""
permissions = permission_bound_field.field._queryset
- # get a distinct list of the content types that these permissions relate to
- content_type_ids = set(permissions.values_list("content_type_id", flat=True))
+ # get a distinct and ordered list of the content types that these permissions relate to.
+ # relies on Permission model default ordering, dict.fromkeys() retaining that order
+ # from the queryset, and the stability of sorted().
+ content_type_ids = sorted(
+ dict.fromkeys(permissions.values_list("content_type_id", flat=True)),
+ key=lambda ct: CONTENT_TYPE_ORDER.get(ct, float("inf")),
+ )
# iterate over permission_bound_field to build a lookup of individual renderable
# checkbox objects
| wagtail/wagtail | f5187d1938b87391ae160116e4d00745787f3155 | diff --git a/wagtail/users/tests/test_admin_views.py b/wagtail/users/tests/test_admin_views.py
index d34b3fff86..37b7502212 100644
--- a/wagtail/users/tests/test_admin_views.py
+++ b/wagtail/users/tests/test_admin_views.py
@@ -24,6 +24,7 @@ from wagtail.models import (
from wagtail.test.utils import WagtailTestUtils
from wagtail.users.forms import UserCreationForm, UserEditForm
from wagtail.users.models import UserProfile
+from wagtail.users.permission_order import register as register_permission_order
from wagtail.users.views.groups import GroupViewSet
from wagtail.users.views.users import get_user_creation_form, get_user_edit_form
from wagtail.users.wagtail_hooks import get_group_viewset_cls
@@ -1947,6 +1948,71 @@ class TestGroupEditView(WagtailTestUtils, TestCase):
# Should not show inputs for publish permissions on models without DraftStateMixin
self.assertNotInHTML("Can publish advert", html)
+ def test_group_edit_loads_with_django_permissions_in_order(self):
+ # ensure objects are ordered as registered, followed by the default ordering
+
+ def object_position(object_perms):
+ # returns the list of objects in the object permsissions
+ # as provided by the format_permissions tag
+
+ def flatten(perm_set):
+ # iterates through perm_set dict, flattens the list if present
+ for v in perm_set.values():
+ if isinstance(v, list):
+ for e in v:
+ yield e
+ else:
+ yield v
+
+ return [
+ (
+ perm.content_type.app_label,
+ perm.content_type.model,
+ )
+ for perm_set in object_perms
+ for perm in [next(v for v in flatten(perm_set) if "perm" in v)["perm"]]
+ ]
+
+ # Set order on two objects, should appear first and second
+ register_permission_order("snippetstests.fancysnippet", order=100)
+ register_permission_order("snippetstests.standardsnippet", order=110)
+
+ response = self.get()
+ object_positions = object_position(response.context["object_perms"])
+ self.assertEqual(
+ object_positions[0],
+ ("snippetstests", "fancysnippet"),
+ msg="Configured object permission order is incorrect",
+ )
+ self.assertEqual(
+ object_positions[1],
+ ("snippetstests", "standardsnippet"),
+ msg="Configured object permission order is incorrect",
+ )
+
+ # Swap order of the objects
+ register_permission_order("snippetstests.standardsnippet", order=90)
+ response = self.get()
+ object_positions = object_position(response.context["object_perms"])
+
+ self.assertEqual(
+ object_positions[0],
+ ("snippetstests", "standardsnippet"),
+ msg="Configured object permission order is incorrect",
+ )
+ self.assertEqual(
+ object_positions[1],
+ ("snippetstests", "fancysnippet"),
+ msg="Configured object permission order is incorrect",
+ )
+
+ # Test remainder of objects are sorted
+ self.assertEqual(
+ object_positions[2:],
+ sorted(object_positions[2:]),
+ msg="Default object permission order is incorrect",
+ )
+
class TestGroupViewSet(TestCase):
def setUp(self):
| Order Object Permissions in the Group Editor
### Is your proposal related to a problem?
The Group Editor - at menu->Settings->Groups or /admin/groups/<<int:group>>/ - allows an administrator to control the permissions each member of the group receives. The "Object Permissions" section, which allows add, change, delete and other model permissions to be edited, are listed in an unmanaged order. The order appears to depend on the migration order, and depending on the development and deployment workflow, results in that ordering being different between development, staging and production deployments.
### Describe the solution you'd like
I would like a solution where the developer can control the order in which each Object type appears. Object permissions can then be placed in a logical order, such as placing related objects together. That order will then be consistent between deployments.
The solution should address objects defined by the developer and within Wagtail itself.
### Describe alternatives you've considered
There appears to be no practical solution to this problem.
### Additional context
I've developed a PR that addresses this, which I'll post shortly. | 0.0 | f5187d1938b87391ae160116e4d00745787f3155 | [
"wagtail/users/tests/test_admin_views.py::TestUserFormHelpers::test_get_user_creation_form_with_custom_form",
"wagtail/users/tests/test_admin_views.py::TestUserFormHelpers::test_get_user_creation_form_with_default_form",
"wagtail/users/tests/test_admin_views.py::TestUserFormHelpers::test_get_user_creation_form_with_invalid_form",
"wagtail/users/tests/test_admin_views.py::TestUserFormHelpers::test_get_user_edit_form_with_custom_form",
"wagtail/users/tests/test_admin_views.py::TestUserFormHelpers::test_get_user_edit_form_with_default_form",
"wagtail/users/tests/test_admin_views.py::TestUserFormHelpers::test_get_user_edit_form_with_invalid_form",
"wagtail/users/tests/test_admin_views.py::TestGroupViewSet::test_get_group_viewset_cls",
"wagtail/users/tests/test_admin_views.py::TestGroupViewSet::test_get_group_viewset_cls_custom_form_does_not_exist",
"wagtail/users/tests/test_admin_views.py::TestGroupViewSet::test_get_group_viewset_cls_custom_form_invalid_value",
"wagtail/users/tests/test_admin_views.py::TestGroupViewSet::test_get_group_viewset_cls_with_custom_form"
]
| []
| {
"failed_lite_validators": [
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2023-05-23 13:24:36+00:00 | bsd-3-clause | 6,215 |
|
wagtail__wagtail-10545 | diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 90ac8ed6e1..4c36a521dc 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -54,6 +54,7 @@ Changelog
* Maintenance: Upgrade Willow to v1.6.2 to support MIME type data without reliance on `imghdr` (Jake Howard)
* Maintenance: Replace `imghdr` with Willow's built-in MIME type detection (Jake Howard)
* Maintenance: Migrate all other `data-tippy` HTML attribute usage to the Stimulus data-*-value attributes for w-tooltip & w-dropdown (Subhajit Ghosh, LB (Ben) Johnston)
+ * Maintenance: Replace `@total_ordering` usage with comparison functions implementation (Virag Jain)
5.1.2 (xx.xx.20xx) - IN DEVELOPMENT
diff --git a/docs/releases/5.2.md b/docs/releases/5.2.md
index aa30a690fa..f411817951 100644
--- a/docs/releases/5.2.md
+++ b/docs/releases/5.2.md
@@ -73,6 +73,7 @@ depth: 1
* Upgrade Willow to v1.6.2 to support MIME type data without reliance on `imghdr` (Jake Howard)
* Replace `imghdr` with Willow's built-in MIME type detection (Jake Howard)
* Migrate all other `data-tippy` HTML attribute usage to the Stimulus data-*-value attributes for w-tooltip & w-dropdown (Subhajit Ghosh, LB (Ben) Johnston)
+ * Replace `@total_ordering` usage with comparison functions implementation (Virag Jain)
## Upgrade considerations - changes affecting all projects
diff --git a/wagtail/admin/search.py b/wagtail/admin/search.py
index 1c666549c2..6f5c338175 100644
--- a/wagtail/admin/search.py
+++ b/wagtail/admin/search.py
@@ -1,5 +1,3 @@
-from functools import total_ordering
-
from django.forms import Media, MediaDefiningClass
from django.forms.utils import flatatt
from django.template.loader import render_to_string
@@ -11,7 +9,6 @@ from wagtail import hooks
from wagtail.admin.forms.search import SearchForm
-@total_ordering
class SearchArea(metaclass=MediaDefiningClass):
template = "wagtailadmin/shared/search_area.html"
@@ -31,9 +28,28 @@ class SearchArea(metaclass=MediaDefiningClass):
self.attr_string = ""
def __lt__(self, other):
+ if not isinstance(other, SearchArea):
+ return NotImplemented
return (self.order, self.label) < (other.order, other.label)
+ def __le__(self, other):
+ if not isinstance(other, SearchArea):
+ return NotImplemented
+ return (self.order, self.label) <= (other.order, other.label)
+
+ def __gt__(self, other):
+ if not isinstance(other, SearchArea):
+ return NotImplemented
+ return (self.order, self.label) > (other.order, other.label)
+
+ def __ge__(self, other):
+ if not isinstance(other, SearchArea):
+ return NotImplemented
+ return (self.order, self.label) >= (other.order, other.label)
+
def __eq__(self, other):
+ if not isinstance(other, SearchArea):
+ return NotImplemented
return (self.order, self.label) == (other.order, other.label)
def is_shown(self, request):
diff --git a/wagtail/admin/widgets/button.py b/wagtail/admin/widgets/button.py
index 5f904f1926..7cc361dbbe 100644
--- a/wagtail/admin/widgets/button.py
+++ b/wagtail/admin/widgets/button.py
@@ -1,5 +1,3 @@
-from functools import total_ordering
-
from django.forms.utils import flatatt
from django.template.loader import render_to_string
from django.utils.functional import cached_property
@@ -8,7 +6,6 @@ from django.utils.html import format_html
from wagtail import hooks
-@total_ordering
class Button:
show = True
@@ -42,6 +39,21 @@ class Button:
return NotImplemented
return (self.priority, self.label) < (other.priority, other.label)
+ def __le__(self, other):
+ if not isinstance(other, Button):
+ return NotImplemented
+ return (self.priority, self.label) <= (other.priority, other.label)
+
+ def __gt__(self, other):
+ if not isinstance(other, Button):
+ return NotImplemented
+ return (self.priority, self.label) > (other.priority, other.label)
+
+ def __ge__(self, other):
+ if not isinstance(other, Button):
+ return NotImplemented
+ return (self.priority, self.label) >= (other.priority, other.label)
+
def __eq__(self, other):
if not isinstance(other, Button):
return NotImplemented
| wagtail/wagtail | ba9f7c898f6d9080daa6dd87100b96e8c6651355 | diff --git a/wagtail/admin/tests/test_admin_search.py b/wagtail/admin/tests/test_admin_search.py
index 2f5594ec69..c6e23092e3 100644
--- a/wagtail/admin/tests/test_admin_search.py
+++ b/wagtail/admin/tests/test_admin_search.py
@@ -3,10 +3,11 @@ Tests for the search box in the admin side menu, and the custom search hooks.
"""
from django.contrib.auth.models import Permission
from django.template import Context, Template
-from django.test import RequestFactory, TestCase
+from django.test import RequestFactory, SimpleTestCase, TestCase
from django.urls import reverse
from wagtail.admin.auth import user_has_any_page_permission
+from wagtail.admin.search import SearchArea
from wagtail.test.utils import WagtailTestUtils
@@ -107,3 +108,91 @@ class TestSearchAreaNoPagePermissions(BaseSearchAreaTestCase):
self.assertNotIn("Pages", rendered)
self.assertIn("My Search", rendered)
+
+
+class SearchAreaComparisonTestCase(SimpleTestCase):
+ """Tests the comparison functions."""
+
+ def setUp(self):
+ self.search_area1 = SearchArea("Label 1", "/url1", order=100)
+ self.search_area2 = SearchArea("Label 2", "/url2", order=200)
+ self.search_area3 = SearchArea("Label 1", "/url3", order=300)
+ self.search_area4 = SearchArea("Label 1", "/url1", order=100)
+
+ def test_eq(self):
+ # Same label and order, should be equal
+ self.assertTrue(self.search_area1 == self.search_area4)
+
+ # Different order, should not be equal
+ self.assertFalse(self.search_area1 == self.search_area2)
+
+ # Not a SearchArea, should not be equal
+ self.assertFalse(self.search_area1 == "Something")
+
+ def test_lt(self):
+ # Less order, should be True
+ self.assertTrue(self.search_area1 < self.search_area2)
+
+ # Same label, but less order, should be True
+ self.assertTrue(self.search_area1 < self.search_area3)
+
+ # Greater order, should be False
+ self.assertFalse(self.search_area2 < self.search_area1)
+
+ # Not a SearchArea, should raise TypeError
+ with self.assertRaises(TypeError):
+ self.search_area1 < "Something"
+
+ def test_le(self):
+ # Less order, should be True
+ self.assertTrue(self.search_area1 <= self.search_area2)
+
+ # Same label, but less order, should be True
+ self.assertTrue(self.search_area1 <= self.search_area3)
+
+ # Same object, should be True
+ self.assertTrue(self.search_area1 <= self.search_area1)
+
+ # Same label and order, should be True
+ self.assertTrue(self.search_area1 <= self.search_area4)
+
+ # Greater order, should be False
+ self.assertFalse(self.search_area2 <= self.search_area1)
+
+ # Not a SearchArea, should raise TypeError
+ with self.assertRaises(TypeError):
+ self.search_area1 <= "Something"
+
+ def test_gt(self):
+ # Greater order, should be True
+ self.assertTrue(self.search_area2 > self.search_area1)
+
+ # Same label, but greater order, should be True
+ self.assertTrue(self.search_area3 > self.search_area1)
+
+ # Less order, should be False
+ self.assertFalse(self.search_area1 > self.search_area2)
+
+ # Not a SearchArea, should raise TypeError
+ with self.assertRaises(TypeError):
+ self.search_area1 > "Something"
+
+ def test_ge(self):
+ # Greater order, should be True
+ self.assertTrue(self.search_area2 >= self.search_area1)
+
+ # Same label, but greater order, should be True
+ self.assertTrue(self.search_area3 >= self.search_area1)
+
+ # Same object, should be True
+ self.assertTrue(self.search_area1 >= self.search_area1)
+
+ # Same label and order, should be True
+ self.assertTrue(self.search_area1 >= self.search_area4)
+
+ # Less order, should be False
+ self.assertFalse(self.search_area1 >= self.search_area2)
+
+ # Not a SearchArea, should raise TypeError
+ with self.assertRaises(TypeError):
+ self.search_area1 >= "Something"
diff --git a/wagtail/admin/tests/test_buttons_hooks.py b/wagtail/admin/tests/test_buttons_hooks.py
index 04b8a39733..820b34816a 100644
--- a/wagtail/admin/tests/test_buttons_hooks.py
+++ b/wagtail/admin/tests/test_buttons_hooks.py
@@ -1,10 +1,11 @@
-from django.test import TestCase
+from django.test import SimpleTestCase, TestCase
from django.urls import reverse
from django.utils.http import urlencode
from wagtail import hooks
from wagtail.admin import widgets as wagtailadmin_widgets
from wagtail.admin.wagtail_hooks import page_header_buttons, page_listing_more_buttons
+from wagtail.admin.widgets.button import Button
from wagtail.models import Page
from wagtail.test.testapp.models import SimplePage
from wagtail.test.utils import WagtailTestUtils
@@ -293,3 +294,98 @@ class TestPageHeaderButtonsHooks(TestButtonsHooks):
unpublish_button = next(buttons)
full_url = unpublish_base_url + "?" + urlencode({"next": next_url})
self.assertEqual(unpublish_button.url, full_url)
+
+
+class ButtonComparisonTestCase(SimpleTestCase):
+ """Tests the comparison functions."""
+
+ def setUp(self):
+ self.button1 = Button(
+ "Label 1", "/url1", classes={"class1", "class2"}, priority=100
+ )
+ self.button2 = Button(
+ "Label 2", "/url2", classes={"class2", "class3"}, priority=200
+ )
+ self.button3 = Button(
+ "Label 1", "/url3", classes={"class1", "class2"}, priority=300
+ )
+ self.button4 = Button(
+ "Label 1", "/url1", classes={"class1", "class2"}, priority=100
+ )
+
+ def test_eq(self):
+ # Same properties, should be equal
+ self.assertTrue(self.button1 == self.button4)
+
+ # Different priority, should not be equal
+ self.assertFalse(self.button1 == self.button2)
+
+ # Different URL, should not be equal
+ self.assertFalse(self.button1 == self.button3)
+
+ # Not a Button, should not be equal
+ self.assertFalse(self.button1 == "Something")
+
+ def test_lt(self):
+ # Less priority, should be True
+ self.assertTrue(self.button1 < self.button2)
+
+ # Same label, but less priority, should be True
+ self.assertTrue(self.button1 < self.button3)
+
+ # Greater priority, should be False
+ self.assertFalse(self.button2 < self.button1)
+
+ # Not a Button, should raise TypeError
+ with self.assertRaises(TypeError):
+ self.button1 < "Something"
+
+ def test_le(self):
+ # Less priority, should be True
+ self.assertTrue(self.button1 <= self.button2)
+
+ # Same label, but less priority, should be True
+ self.assertTrue(self.button1 <= self.button3)
+
+ # Same object, should be True
+ self.assertTrue(self.button1 <= self.button1)
+
+ # Same label and priority, should be True
+ self.assertTrue(self.button1 <= self.button4)
+
+ # Greater priority, should be False
+ self.assertFalse(self.button2 <= self.button1)
+
+ # Not a Button, should raise TypeError
+ with self.assertRaises(TypeError):
+ self.button1 <= "Something"
+
+ def test_gt(self):
+ # Greater priority, should be True
+ self.assertTrue(self.button2 > self.button1)
+
+ # Same label, but greater priority, should be True
+ self.assertTrue(self.button3 > self.button1)
+
+ # Less priority, should be False
+ self.assertFalse(self.button1 > self.button2)
+
+ # Not a Button, should raise TypeError
+ with self.assertRaises(TypeError):
+ self.button1 > "Something"
+
+ def test_ge(self):
+ # Greater priority, should be True
+ self.assertTrue(self.button2 >= self.button1)
+
+ # Same label, but greater priority, should be True
+ self.assertTrue(self.button3 >= self.button1)
+
+ # Same object, should be True
+ self.assertTrue(self.button1 >= self.button1)
+
+ # Same label and priority, should be True
+ self.assertTrue(self.button1 >= self.button4)
+
+ # Less priority, should be False
+ self.assertFalse(self.button1 >= self.button2)
| Replace `total_ordering` usage with comparison functions implementation
### Is your proposal related to a problem?
We have two instances of `total_ordering` usage within the codebase:
https://github.com/wagtail/wagtail/blob/cd5200c8e1ac0d7299fd9c398b2b994606b3c7d2/wagtail/admin/search.py#L12-L13
https://github.com/wagtail/wagtail/blob/cd5200c8e1ac0d7299fd9c398b2b994606b3c7d2/wagtail/admin/widgets/button.py#L11-L12
Even though it's convenient, `total_ordering` is known to be slow. According to [Python's docs](https://docs.python.org/3/library/functools.html#functools.total_ordering):
> **Note**
> While this decorator makes it easy to create well behaved totally ordered types, it does come at the cost of slower execution and more complex stack traces for the derived comparison methods. If performance benchmarking indicates this is a bottleneck for a given application, implementing all six rich comparison methods instead is likely to provide an easy speed boost.
Django recently removed their usage of `total_ordering` in https://github.com/django/django/pull/16958/commits/ee36e101e8f8c0acde4bb148b738ab7034e902a0 (probably not all usages, I haven't checked).
### Describe the solution you'd like
<!--
Provide a clear and concise description of what you want to happen.
-->
Replace `total_ordering` with implementations of `__eq__()`, `__ne__()`, `__lt__()`, `__le__()`, `__gt__()`, and `__ge__()`.
### Describe alternatives you've considered
<!--
Let us know about other solutions you've tried or researched.
-->
Keep using `total_ordering`
### Additional context
I found this while fixing an incorrect import of `total_ordering` in #10525.
| 0.0 | ba9f7c898f6d9080daa6dd87100b96e8c6651355 | [
"wagtail/admin/tests/test_admin_search.py::SearchAreaComparisonTestCase::test_eq",
"wagtail/admin/tests/test_admin_search.py::SearchAreaComparisonTestCase::test_ge",
"wagtail/admin/tests/test_admin_search.py::SearchAreaComparisonTestCase::test_gt",
"wagtail/admin/tests/test_admin_search.py::SearchAreaComparisonTestCase::test_le",
"wagtail/admin/tests/test_admin_search.py::SearchAreaComparisonTestCase::test_lt"
]
| [
"wagtail/admin/tests/test_buttons_hooks.py::ButtonComparisonTestCase::test_eq",
"wagtail/admin/tests/test_buttons_hooks.py::ButtonComparisonTestCase::test_ge",
"wagtail/admin/tests/test_buttons_hooks.py::ButtonComparisonTestCase::test_gt",
"wagtail/admin/tests/test_buttons_hooks.py::ButtonComparisonTestCase::test_le",
"wagtail/admin/tests/test_buttons_hooks.py::ButtonComparisonTestCase::test_lt"
]
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false
} | 2023-06-11 17:53:30+00:00 | bsd-3-clause | 6,216 |
|
wagtail__wagtail-7427 | diff --git a/wagtail/embeds/finders/oembed.py b/wagtail/embeds/finders/oembed.py
index d2da0edf50..6151b5a1b2 100644
--- a/wagtail/embeds/finders/oembed.py
+++ b/wagtail/embeds/finders/oembed.py
@@ -87,8 +87,11 @@ class OEmbedFinder(EmbedFinder):
'html': html,
}
- cache_age = oembed.get('cache_age')
- if cache_age is not None:
+ try:
+ cache_age = int(oembed['cache_age'])
+ except (KeyError, TypeError, ValueError):
+ pass
+ else:
result['cache_until'] = timezone.now() + timedelta(seconds=cache_age)
return result
| wagtail/wagtail | 1efbfd49940206f22c6b4819cc1beb6fbc1c08a0 | diff --git a/wagtail/embeds/tests/test_embeds.py b/wagtail/embeds/tests/test_embeds.py
index ccabcc8c0b..d8c1a6cb57 100644
--- a/wagtail/embeds/tests/test_embeds.py
+++ b/wagtail/embeds/tests/test_embeds.py
@@ -490,6 +490,37 @@ class TestOembed(TestCase):
'cache_until': make_aware(datetime.datetime(2001, 2, 3, hour=1))
})
+ @patch('django.utils.timezone.now')
+ @patch('urllib.request.urlopen')
+ @patch('json.loads')
+ def test_oembed_cache_until_as_string(self, loads, urlopen, now):
+ urlopen.return_value = self.dummy_response
+ loads.return_value = {
+ 'type': 'something',
+ 'url': 'http://www.example.com',
+ 'title': 'test_title',
+ 'author_name': 'test_author',
+ 'provider_name': 'test_provider_name',
+ 'thumbnail_url': 'test_thumbail_url',
+ 'width': 'test_width',
+ 'height': 'test_height',
+ 'html': 'test_html',
+ 'cache_age': '3600'
+ }
+ now.return_value = make_aware(datetime.datetime(2001, 2, 3))
+ result = OEmbedFinder().find_embed("http://www.youtube.com/watch/")
+ self.assertEqual(result, {
+ 'type': 'something',
+ 'title': 'test_title',
+ 'author_name': 'test_author',
+ 'provider_name': 'test_provider_name',
+ 'thumbnail_url': 'test_thumbail_url',
+ 'width': 'test_width',
+ 'height': 'test_height',
+ 'html': 'test_html',
+ 'cache_until': make_aware(datetime.datetime(2001, 2, 3, hour=1))
+ })
+
def test_oembed_accepts_known_provider(self):
finder = OEmbedFinder(providers=[oembed_providers.youtube])
self.assertTrue(finder.accept("http://www.youtube.com/watch/"))
| Parsing cache_until field fails on Twitter embeds
Reported on Slack #support: Trying to embed a twitter link within a RichField paragraph triggers a 500 error.
```
ERROR 2021-08-08 19:41:11,207 log 2288 140316583144768 Internal Server Error: /cms/embeds/chooser/upload/
...
...
File "/home/asdf/asdffff/venv/lib/python3.7/site-packages/wagtail/embeds/finders/oembed.py", line 92, in find_embed
result['cache_until'] = timezone.now() + timedelta(seconds=cache_age)
TypeError: unsupported type for timedelta seconds component: str
```
The response returned by Twitter's oembed endpoint is:
```
{'url': 'https://twitter.com/elonmusk/status/1423659261452709893', 'author_name': 'Elon Musk', 'author_url': 'https://twitter.com/elonmusk', 'html': '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Starship Fully Stacked <a href="https://t.co/Fs88RNsmfH">pic.twitter.com/Fs88RNsmfH</a></p>— Elon Musk (@elonmusk) <a href="https://twitter.com/elonmusk/status/1423659261452709893?ref_src=twsrc%5Etfw">August 6, 2021</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>\n', 'width': 550, 'height': None, 'type': 'rich', 'cache_age': '3153600000', 'provider_name': 'Twitter', 'provider_url': 'https://twitter.com', 'version': '1.0'}
```
so it looks like we aren't handling `cache_age` being returned as a string rather than an int.
Checking `cache_age` was added in #7279, so this is most likely a 2.14 regression. | 0.0 | 1efbfd49940206f22c6b4819cc1beb6fbc1c08a0 | [
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_cache_until_as_string"
]
| [
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_defaults_to_oembed",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_find_facebook_oembed_with_options",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_find_instagram_oembed_with_options",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_new_find_embedly",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_new_find_oembed",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_new_find_oembed_with_options",
"wagtail/embeds/tests/test_embeds.py::TestEmbedHash::test_get_embed_hash",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_endpoint_with_format_param",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_accepts_known_provider",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_cache_until",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_doesnt_accept_unknown_provider",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_invalid_provider",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_invalid_request",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_non_json_response",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_photo_request",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_return_values",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_failed_request",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_oembed_only_accepts_new_url_patterns",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_oembed_return_values",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_request_denied_401",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_request_not_found",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_failed_request",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_oembed_accepts_various_url_patterns",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_oembed_return_values",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_request_denied_401",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_request_not_found",
"wagtail/embeds/tests/test_embeds.py::TestEmbedTag::test_direct_call",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_clean_invalid_url",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_default",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_deserialize",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_serialize",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_value_from_form"
]
| {
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-08-11 17:02:47+00:00 | bsd-3-clause | 6,217 |
|
wagtail__wagtail-8006 | diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 6371280bcb..a8a8f7efe9 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -34,6 +34,7 @@ Changelog
* Remove `replace_text` management command (Sage Abdullah)
* Replace `data_json` `TextField` with `data` `JSONField` in `BaseLogEntry` (Sage Abdullah)
* Split up linting / formatting tasks in Makefile into client and server components (Hitansh Shah)
+ * Add support for embedding Instagram reels (Luis Nell)
* Fix: When using `simple_translations` ensure that the user is redirected to the page edit view when submitting for a single locale (Mitchel Cabuloy)
* Fix: When previewing unsaved changes to `Form` pages, ensure that all added fields are correctly shown in the preview (Joshua Munn)
* Fix: When Documents (e.g. PDFs) have been configured to be served inline via `WAGTAILDOCS_CONTENT_TYPES` & `WAGTAILDOCS_INLINE_CONTENT_TYPES` ensure that the filename is correctly set in the `Content-Disposition` header so that saving the files will use the correct filename (John-Scott Atlakson)
diff --git a/docs/releases/3.0.md b/docs/releases/3.0.md
index bed4be6735..3f198c7555 100644
--- a/docs/releases/3.0.md
+++ b/docs/releases/3.0.md
@@ -56,6 +56,7 @@ The panel types `StreamFieldPanel`, `RichTextFieldPanel`, `ImageChooserPanel`, `
* Update Jinja2 template support for Jinja2 3.x (Seb Brown)
* Add ability for `StreamField` to use `JSONField` to store data, rather than `TextField` (Sage Abdullah)
* Split up linting / formatting tasks in Makefile into client and server components (Hitansh Shah)
+ * Add support for embedding Instagram reels (Luis Nell)
### Bug fixes
@@ -156,3 +157,9 @@ When overriding the `get_form_class` method of a ModelAdmin `CreateView` or `Edi
`StreamField` now requires a `use_json_field` keyword argument that can be set to `True`/`False`. If set to `True`, the field will use `JSONField` as its internal type instead of `TextField`, which will change the data type used on the database and allow you to use `JSONField` lookups and transforms on the `StreamField`. If set to `False`, the field will keep its previous behaviour and no database changes will be made. If set to `None` (the default), the field will keep its previous behaviour and a warning (`RemovedInWagtail50Warning`) will appear.
After setting the keyword argument, make sure to generate and run the migrations for the models.
+
+### Removal of legacy `clean_name` on `AbstractFormField`
+
+- If you have a project migrating from pre 2.10 to this release and you are using the Wagtail form builder and you have existing form submissions you must first upgrade to at least 2.11. Then run migrations and run the application with your data to ensure that any existing form fields are correctly migrated.
+- In Wagtail 2.10 a `clean_name` field was added to form field models that extend `AbstractFormField` and this initially supported legacy migration of the [Unidecode](https://pypi.org/project/Unidecode/) label conversion.
+- Any new fields created since then will have used the [AnyAscii](https://pypi.org/project/anyascii/) conversion and Unidecode has been removed from the included packages.
diff --git a/setup.py b/setup.py
index 039b36031b..120ab0dbe9 100755
--- a/setup.py
+++ b/setup.py
@@ -49,7 +49,6 @@ testing_extras = [
"boto3>=1.16,<1.17",
"freezegun>=0.3.8",
"openpyxl>=2.6.4",
- "Unidecode>=0.04.14,<2.0",
"azure-mgmt-cdn>=5.1,<6.0",
"azure-mgmt-frontdoor>=0.3,<0.4",
"django-pattern-library>=0.7,<0.8",
diff --git a/wagtail/contrib/forms/models.py b/wagtail/contrib/forms/models.py
index 2b32cf20ca..f29e33dbb6 100644
--- a/wagtail/contrib/forms/models.py
+++ b/wagtail/contrib/forms/models.py
@@ -3,13 +3,10 @@ import json
import os
from django.conf import settings
-from django.core.checks import Info
-from django.core.exceptions import FieldError
from django.core.serializers.json import DjangoJSONEncoder
-from django.db import DatabaseError, models
+from django.db import models
from django.template.response import TemplateResponse
from django.utils.formats import date_format
-from django.utils.text import slugify
from django.utils.translation import gettext_lazy as _
from wagtail.admin.mail import send_mail
@@ -142,45 +139,6 @@ class AbstractFormField(Orderable):
super().save(*args, **kwargs)
- @classmethod
- def _migrate_legacy_clean_name(cls):
- """
- Ensure that existing data stored will be accessible via the legacy clean_name.
- When checks run, replace any blank clean_name values with the unidecode conversion.
- """
-
- try:
- objects = cls.objects.filter(clean_name__exact="")
- if objects.count() == 0:
- return None
-
- except (FieldError, DatabaseError):
- # attempting to query on clean_name before field has been added
- return None
-
- try:
- from unidecode import unidecode
- except ImportError as error:
- description = "You have form submission data that was created on an older version of Wagtail and requires the unidecode library to retrieve it correctly. Please install the unidecode package."
- raise Exception(description) from error
-
- for obj in objects:
- legacy_clean_name = str(slugify(str(unidecode(obj.label))))
- obj.clean_name = legacy_clean_name
- obj.save()
-
- return Info("Added `clean_name` on %s form field(s)" % objects.count(), obj=cls)
-
- @classmethod
- def check(cls, **kwargs):
- errors = super().check(**kwargs)
-
- messages = cls._migrate_legacy_clean_name()
- if messages:
- errors.append(messages)
-
- return errors
-
class Meta:
abstract = True
ordering = ["sort_order"]
diff --git a/wagtail/embeds/finders/instagram.py b/wagtail/embeds/finders/instagram.py
index f490cb685e..458248d1bc 100644
--- a/wagtail/embeds/finders/instagram.py
+++ b/wagtail/embeds/finders/instagram.py
@@ -24,6 +24,7 @@ class InstagramOEmbedFinder(EmbedFinder):
INSTAGRAM_URL_PATTERNS = [
r"^https?://(?:www\.)?instagram\.com/p/.+$",
r"^https?://(?:www\.)?instagram\.com/tv/.+$",
+ r"^https?://(?:www\.)?instagram\.com/reel/.+$",
]
def __init__(self, omitscript=False, app_id=None, app_secret=None):
diff --git a/wagtail/images/models.py b/wagtail/images/models.py
index 986b841f95..3c6103fae0 100644
--- a/wagtail/images/models.py
+++ b/wagtail/images/models.py
@@ -187,7 +187,7 @@ class AbstractImage(ImageFileMixin, CollectionMember, index.Indexed, models.Mode
folder_name = "original_images"
filename = self.file.field.storage.get_valid_name(filename)
- # do a unidecode in the filename and then
+ # convert the filename to simple ascii characters and then
# replace non-ascii characters in filename with _ , to sidestep issues with filesystem encoding
filename = "".join(
(i if ord(i) < 128 else "_") for i in string_to_ascii(filename)
| wagtail/wagtail | 97e781e31c3bb227970b174dc16fb7febb630571 | diff --git a/wagtail/contrib/forms/tests/test_models.py b/wagtail/contrib/forms/tests/test_models.py
index 4b2ad1bef7..d9567ca1b3 100644
--- a/wagtail/contrib/forms/tests/test_models.py
+++ b/wagtail/contrib/forms/tests/test_models.py
@@ -4,7 +4,6 @@ import unittest
from django import VERSION as DJANGO_VERSION
from django.core import mail
-from django.core.checks import Info
from django.test import TestCase, override_settings
from wagtail.contrib.forms.models import FormSubmission
@@ -19,7 +18,6 @@ from wagtail.test.testapp.models import (
CustomFormPageSubmission,
ExtendedFormField,
FormField,
- FormFieldWithCustomSubmission,
FormPageWithCustomFormBuilder,
JadeFormPage,
)
@@ -809,75 +807,3 @@ class TestNonHtmlExtension(TestCase):
self.assertEqual(
form_page.landing_page_template, "tests/form_page_landing.jade"
)
-
-
-class TestLegacyFormFieldCleanNameChecks(TestCase, WagtailTestUtils):
- fixtures = ["test.json"]
-
- def setUp(self):
- self.login(username="siteeditor", password="password")
- self.form_page = Page.objects.get(
- url_path="/home/contact-us-one-more-time/"
- ).specific
-
- def test_form_field_clean_name_update_on_checks(self):
- fields_before_checks = [
- (
- field.label,
- field.clean_name,
- )
- for field in FormFieldWithCustomSubmission.objects.all()
- ]
-
- self.assertEqual(
- fields_before_checks,
- [
- ("Your email", ""),
- ("Your message", ""),
- ("Your choices", ""),
- ],
- )
-
- # running checks should show an info message AND update blank clean_name values
-
- messages = FormFieldWithCustomSubmission.check()
-
- self.assertEqual(
- messages,
- [
- Info(
- "Added `clean_name` on 3 form field(s)",
- obj=FormFieldWithCustomSubmission,
- )
- ],
- )
-
- fields_after_checks = [
- (
- field.label,
- field.clean_name,
- )
- for field in FormFieldWithCustomSubmission.objects.all()
- ]
-
- self.assertEqual(
- fields_after_checks,
- [
- ("Your email", "your-email"), # kebab case, legacy format
- ("Your message", "your-message"),
- ("Your choices", "your-choices"),
- ],
- )
-
- # running checks again should return no messages as fields no longer need changing
- self.assertEqual(FormFieldWithCustomSubmission.check(), [])
-
- # creating a new field should use the non-legacy clean_name format
-
- field = FormFieldWithCustomSubmission.objects.create(
- page=self.form_page,
- label="Your FAVOURITE #number",
- field_type="number",
- )
-
- self.assertEqual(field.clean_name, "your_favourite_number")
diff --git a/wagtail/contrib/forms/tests/test_views.py b/wagtail/contrib/forms/tests/test_views.py
index 4491015781..9b06dfb062 100644
--- a/wagtail/contrib/forms/tests/test_views.py
+++ b/wagtail/contrib/forms/tests/test_views.py
@@ -5,7 +5,6 @@ from io import BytesIO
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
-from django.core.checks import Info
from django.test import RequestFactory, TestCase, override_settings
from django.urls import reverse
from openpyxl import load_workbook
@@ -522,49 +521,6 @@ class TestFormsSubmissionsList(TestCase, WagtailTestUtils):
self.assertIn("this is a really old message", first_row_values)
-class TestFormsSubmissionsListLegacyFieldName(TestCase, WagtailTestUtils):
- fixtures = ["test.json"]
-
- def setUp(self):
- self.login(username="siteeditor", password="password")
- self.form_page = Page.objects.get(
- url_path="/home/contact-us-one-more-time/"
- ).specific
-
- # running checks should show an info message AND update blank clean_name values
-
- messages = FormFieldWithCustomSubmission.check()
-
- self.assertEqual(
- messages,
- [
- Info(
- "Added `clean_name` on 3 form field(s)",
- obj=FormFieldWithCustomSubmission,
- )
- ],
- )
-
- # check clean_name has been updated
- self.assertEqual(
- FormFieldWithCustomSubmission.objects.all()[0].clean_name, "your-email"
- )
-
- def test_list_submissions(self):
- response = self.client.get(
- reverse("wagtailforms:list_submissions", args=(self.form_page.id,))
- )
-
- # Check response
- self.assertEqual(response.status_code, 200)
- self.assertTemplateUsed(response, "wagtailforms/index_submissions.html")
- self.assertEqual(len(response.context["data_rows"]), 2)
-
- # check display of list values within form submissions
- self.assertContains(response, "[email protected]")
- self.assertContains(response, "[email protected]")
-
-
class TestFormsSubmissionsExport(TestCase, WagtailTestUtils):
def setUp(self):
# Create a form page
diff --git a/wagtail/embeds/tests/test_embeds.py b/wagtail/embeds/tests/test_embeds.py
index 40255d5602..5257dba19f 100644
--- a/wagtail/embeds/tests/test_embeds.py
+++ b/wagtail/embeds/tests/test_embeds.py
@@ -634,6 +634,16 @@ class TestInstagramOEmbed(TestCase):
"https://www.instagram.com/p/CHeRxmnDSYe/?utm_source=ig_embed"
)
)
+ self.assertTrue(
+ finder.accept(
+ "https://www.instagram.com/tv/CZMkxGaIXk3/?utm_source=ig_embed"
+ )
+ )
+ self.assertTrue(
+ finder.accept(
+ "https://www.instagram.com/reel/CZMs3O_I22w/?utm_source=ig_embed"
+ )
+ )
self.assertFalse(
finder.accept("https://instagr.am/p/CHeRxmnDSYe/?utm_source=ig_embed")
)
@@ -659,8 +669,6 @@ class TestInstagramOEmbed(TestCase):
)
# check that a request was made with the expected URL / authentication
request = urlopen.call_args[0][0]
- # check that a request was made with the expected URL / authentication
- request = urlopen.call_args[0][0]
self.assertEqual(
request.get_full_url(),
"https://graph.facebook.com/v11.0/instagram_oembed?url=https%3A%2F%2Finstagr.am%2Fp%2FCHeRxmnDSYe%2F&format=json",
diff --git a/wagtail/test/testapp/fixtures/test.json b/wagtail/test/testapp/fixtures/test.json
index 074a0b696f..65fb8028f4 100644
--- a/wagtail/test/testapp/fixtures/test.json
+++ b/wagtail/test/testapp/fixtures/test.json
@@ -487,7 +487,7 @@
"pk": 1,
"model": "tests.formfieldwithcustomsubmission",
"fields": {
- "clean_name": "",
+ "clean_name": "your_email",
"sort_order": 1,
"label": "Your email",
"field_type": "email",
@@ -502,7 +502,7 @@
"pk": 2,
"model": "tests.formfieldwithcustomsubmission",
"fields": {
- "clean_name": "",
+ "clean_name": "your_message",
"sort_order": 2,
"label": "Your message",
"field_type": "multiline",
@@ -517,7 +517,7 @@
"pk": 3,
"model": "tests.formfieldwithcustomsubmission",
"fields": {
- "clean_name": "",
+ "clean_name": "your_choices",
"sort_order": 3,
"label": "Your choices",
"field_type": "checkboxes",
| remove unidecode and legacy form field clean name
In Wagtail 2.10 the usage of unidecode was replaced with anyascii to ensure that the licenses used in Wagtail were compatible.
However, we still have not removed the legacy approach and the package.
After multiple subsequent releases, I think it is time to do this.
https://github.com/wagtail/wagtail/blob/7e6755ec625cf8a014f4218e0a65533a324ef5aa/wagtail/contrib/forms/models.py#L157
See https://github.com/wagtail/wagtail/issues/3311
| 0.0 | 97e781e31c3bb227970b174dc16fb7febb630571 | [
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_oembed_only_accepts_new_url_patterns"
]
| [
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_defaults_to_oembed",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_find_facebook_oembed_with_options",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_find_instagram_oembed_with_options",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_new_find_embedly",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_new_find_oembed",
"wagtail/embeds/tests/test_embeds.py::TestGetFinders::test_new_find_oembed_with_options",
"wagtail/embeds/tests/test_embeds.py::TestEmbedHash::test_get_embed_hash",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_endpoint_with_format_param",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_accepts_known_provider",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_cache_until",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_cache_until_as_string",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_doesnt_accept_unknown_provider",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_invalid_provider",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_invalid_request",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_non_json_response",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_photo_request",
"wagtail/embeds/tests/test_embeds.py::TestOembed::test_oembed_return_values",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_failed_request",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_oembed_return_values",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_request_denied_401",
"wagtail/embeds/tests/test_embeds.py::TestInstagramOEmbed::test_instagram_request_not_found",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_failed_request",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_oembed_accepts_various_url_patterns",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_oembed_return_values",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_request_denied_401",
"wagtail/embeds/tests/test_embeds.py::TestFacebookOEmbed::test_facebook_request_not_found",
"wagtail/embeds/tests/test_embeds.py::TestEmbedTag::test_call_from_template",
"wagtail/embeds/tests/test_embeds.py::TestEmbedTag::test_catches_embed_not_found",
"wagtail/embeds/tests/test_embeds.py::TestEmbedTag::test_direct_call",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_clean_invalid_url",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_clean_non_required",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_clean_required",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_default",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_deserialize",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_render",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_render_within_structblock",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_serialize",
"wagtail/embeds/tests/test_embeds.py::TestEmbedBlock::test_value_from_form"
]
| {
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-02-17 11:04:55+00:00 | bsd-3-clause | 6,218 |
|
wagtail__wagtail-8993 | diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 517cc23cf2..4b95ea22c3 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -163,6 +163,7 @@ Changelog
* Fix: Layout issues with reports (including form submissions listings) on md device widths (Akash Kumar Sen, LB (Ben) Johnston)
* Fix: Layout issue with page explorer's inner header item on small device widths (Akash Kumar Sen)
* Fix: Ensure that `BaseSiteSetting` / `BaseGenericSetting` objects can be pickled (Andy Babic)
+ * Fix: Ensure `DocumentChooserBlock` can be deconstructed for migrations (Matt Westcott)
3.0.1 (16.06.2022)
diff --git a/client/src/entrypoints/admin/page-editor.js b/client/src/entrypoints/admin/page-editor.js
index dd050952a9..da30ddbfff 100644
--- a/client/src/entrypoints/admin/page-editor.js
+++ b/client/src/entrypoints/admin/page-editor.js
@@ -94,7 +94,6 @@ function InlinePanel(opts) {
forms.each(function updateButtonStates(i) {
const isFirst = i === 0;
const isLast = i === forms.length - 1;
- console.log(isFirst, isLast);
$('[data-inline-panel-child-move-up]', this).prop('disabled', isFirst);
$('[data-inline-panel-child-move-down]', this).prop('disabled', isLast);
});
diff --git a/client/src/includes/breadcrumbs.js b/client/src/includes/breadcrumbs.js
index 6322500e8a..eb60b5cd31 100644
--- a/client/src/includes/breadcrumbs.js
+++ b/client/src/includes/breadcrumbs.js
@@ -15,6 +15,8 @@ export default function initCollapsibleBreadcrumbs() {
'[data-toggle-breadcrumbs]',
);
+ if (!breadcrumbsToggle) return;
+
const breadcrumbItems = breadcrumbsContainer.querySelectorAll(
'[data-breadcrumb-item]',
);
diff --git a/docs/extending/generic_views.md b/docs/extending/generic_views.md
index b003c33ee4..f506ab4164 100644
--- a/docs/extending/generic_views.md
+++ b/docs/extending/generic_views.md
@@ -96,6 +96,10 @@ The viewset also makes a StreamField chooser block class available, as the prope
from .views import person_chooser_viewset
PersonChooserBlock = person_chooser_viewset.block_class
+
+# When deconstructing a PersonChooserBlock instance for migrations, the module path
+# used in migrations should point back to this module
+PersonChooserBlock.__module__ = "myapp.blocks"
```
## Chooser viewsets for non-model datasources
diff --git a/docs/releases/4.0.md b/docs/releases/4.0.md
index a6d74c9ce5..4411cb18a1 100644
--- a/docs/releases/4.0.md
+++ b/docs/releases/4.0.md
@@ -220,6 +220,7 @@ The bulk of these enhancements have been from Paarth Agarwal, who has been doing
* Resolve layout issues with reports (including form submissions listings) on md device widths (Akash Kumar Sen, LB (Ben) Johnston)
* Resolve Layout issue with page explorer's inner header item on small device widths (Akash Kumar Sen)
* Ensure that `BaseSiteSetting` / `BaseGenericSetting` objects can be pickled (Andy Babic)
+ * Ensure `DocumentChooserBlock` can be deconstructed for migrations (Matt Westcott)
## Upgrade considerations
diff --git a/wagtail/documents/blocks.py b/wagtail/documents/blocks.py
index 291fa803ab..31af414252 100644
--- a/wagtail/documents/blocks.py
+++ b/wagtail/documents/blocks.py
@@ -1,3 +1,7 @@
from wagtail.documents.views.chooser import viewset as chooser_viewset
DocumentChooserBlock = chooser_viewset.block_class
+
+# When deconstructing a DocumentChooserBlock instance for migrations, the module path
+# used in migrations should point to this module
+DocumentChooserBlock.__module__ = "wagtail.documents.blocks"
| wagtail/wagtail | 5ff6922eb517015651b9012bd6534a912a50b449 | diff --git a/wagtail/documents/tests/test_blocks.py b/wagtail/documents/tests/test_blocks.py
new file mode 100644
index 0000000000..031dad9af1
--- /dev/null
+++ b/wagtail/documents/tests/test_blocks.py
@@ -0,0 +1,12 @@
+from django.test import TestCase
+
+from wagtail.documents.blocks import DocumentChooserBlock
+
+
+class TestDocumentChooserBlock(TestCase):
+ def test_deconstruct(self):
+ block = DocumentChooserBlock(required=False)
+ path, args, kwargs = block.deconstruct()
+ self.assertEqual(path, "wagtail.documents.blocks.DocumentChooserBlock")
+ self.assertEqual(args, ())
+ self.assertEqual(kwargs, {"required": False})
diff --git a/wagtail/images/tests/test_blocks.py b/wagtail/images/tests/test_blocks.py
index 904398e34c..bf8d537786 100644
--- a/wagtail/images/tests/test_blocks.py
+++ b/wagtail/images/tests/test_blocks.py
@@ -63,3 +63,10 @@ class TestImageChooserBlock(TestCase):
)
self.assertHTMLEqual(html, expected_html)
+
+ def test_deconstruct(self):
+ block = ImageChooserBlock(required=False)
+ path, args, kwargs = block.deconstruct()
+ self.assertEqual(path, "wagtail.images.blocks.ImageChooserBlock")
+ self.assertEqual(args, ())
+ self.assertEqual(kwargs, {"required": False})
diff --git a/wagtail/snippets/tests/test_snippets.py b/wagtail/snippets/tests/test_snippets.py
index c9cbcfb156..54c592d4e5 100644
--- a/wagtail/snippets/tests/test_snippets.py
+++ b/wagtail/snippets/tests/test_snippets.py
@@ -3174,6 +3174,13 @@ class TestSnippetChooserBlock(TestCase):
self.assertEqual(nonrequired_block.clean(test_advert), test_advert)
self.assertIsNone(nonrequired_block.clean(None))
+ def test_deconstruct(self):
+ block = SnippetChooserBlock(Advert, required=False)
+ path, args, kwargs = block.deconstruct()
+ self.assertEqual(path, "wagtail.snippets.blocks.SnippetChooserBlock")
+ self.assertEqual(args, (Advert,))
+ self.assertEqual(kwargs, {"required": False})
+
class TestAdminSnippetChooserWidget(TestCase, WagtailTestUtils):
def test_adapt(self):
| Breadcrumbs JavaScript error on root page listing / index (4.0 RC)
### Issue Summary
The breadcrumbs on the page listing under the root page is triggering a JavaScript error.
### Steps to Reproduce
1. Start a new project with `wagtail start myproject`
2. Load up the Wagtail admin
3. Navigate to the root page
4. Expected: No console errors
5. Actual: Console error triggers `Uncaught TypeError: breadcrumbsToggle is null` (note: error is not as clear in the compressed JS build).
- I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: no
### Technical details
- Python version: 3.9
- Django version: 4.0
- Wagtail version: 4.0 RC1
- Browser version: Firefox 103.0 (64-bit) on macOS 12.3
**Full error**
```
Uncaught TypeError: breadcrumbsToggle is null
initCollapsibleBreadcrumbs breadcrumbs.js:50
<anonymous> wagtailadmin.js:37
EventListener.handleEvent* wagtailadmin.js:30
js wagtailadmin.js:72
__webpack_require__ wagtailadmin.js:184
__webpack_exports__ wagtailadmin.js:348
O wagtailadmin.js:221
<anonymous> wagtailadmin.js:349
<anonymous> wagtailadmin.js:351
[breadcrumbs.js:50](webpack://wagtail/client/src/includes/breadcrumbs.js?b04c)
initCollapsibleBreadcrumbs breadcrumbs.js:50
<anonymous> wagtailadmin.js:37
(Async: EventListener.handleEvent)
<anonymous> wagtailadmin.js:30
js wagtailadmin.js:72
__webpack_require__ wagtailadmin.js:184
__webpack_exports__ wagtailadmin.js:348
O wagtailadmin.js:221
<anonymous> wagtailadmin.js:349
<anonymous> wagtailadmin.js:351
```
### Likely root cause
* `data-breadcrumbs-next` is still being rendered even though the root breadcrumbs are not collapsible
* https://github.com/wagtail/wagtail/blob/5ff6922eb517015651b9012bd6534a912a50b449/wagtail/admin/templates/wagtailadmin/pages/page_listing_header.html#L11
* https://github.com/wagtail/wagtail/blob/5ff6922eb517015651b9012bd6534a912a50b449/wagtail/admin/templates/wagtailadmin/shared/breadcrumbs.html#L11
* https://github.com/wagtail/wagtail/blob/5ff6922eb517015651b9012bd6534a912a50b449/client/src/includes/breadcrumbs.js#L14-L16
* Maybe when content is not collapsible we should not be adding the `data-breadcrumbs-next` so that the JS does not try to init the toggle at all OR maybe we should add extra logic to the JS so that it does not try to init the toggle if it is not present in the DOM. Preference would be to ensure the data attribute is not set when JS logic is not required.
### Screenshot
<img width="1557" alt="Screen Shot 2022-08-14 at 3 15 08 pm" src="https://user-images.githubusercontent.com/1396140/184523614-d44f9a69-a2b5-46cc-b638-eeb5e6435f28.png">
| 0.0 | 5ff6922eb517015651b9012bd6534a912a50b449 | [
"wagtail/documents/tests/test_blocks.py::TestDocumentChooserBlock::test_deconstruct"
]
| [
"wagtail/snippets/tests/test_snippets.py::TestSnippetRegistering::test_register_decorator",
"wagtail/snippets/tests/test_snippets.py::TestSnippetRegistering::test_register_function",
"wagtail/snippets/tests/test_snippets.py::TestSnippetOrdering::test_snippets_ordering",
"wagtail/snippets/tests/test_snippets.py::TestSnippetEditHandlers::test_fancy_edit_handler",
"wagtail/snippets/tests/test_snippets.py::TestSnippetEditHandlers::test_get_snippet_edit_handler",
"wagtail/snippets/tests/test_snippets.py::TestSnippetEditHandlers::test_standard_edit_handler",
"wagtail/snippets/tests/test_snippets.py::TestAdminSnippetChooserWidget::test_adapt",
"wagtail/snippets/tests/test_snippets.py::TestPanelConfigurationChecks::test_model_with_single_tabbed_panel_only"
]
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_media",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2022-08-14 05:56:29+00:00 | bsd-3-clause | 6,219 |
|
wagtail__wagtail-9920 | diff --git a/wagtail/admin/templates/wagtailadmin/userbar/base.html b/wagtail/admin/templates/wagtailadmin/userbar/base.html
index ee3629e736..247652249d 100644
--- a/wagtail/admin/templates/wagtailadmin/userbar/base.html
+++ b/wagtail/admin/templates/wagtailadmin/userbar/base.html
@@ -51,7 +51,7 @@
</template>
<template id="w-a11y-result-selector-template">
<button class="w-a11y-result__selector" data-a11y-result-selector type="button">
- {% icon name="crosshairs" class_name="w-a11y-result__icon" %}
+ {% icon name="crosshairs" classname="w-a11y-result__icon" %}
<span data-a11y-result-selector-text></span>
</button>
</template>
diff --git a/wagtail/admin/templates/wagtailadmin/workflows/includes/workflow_content_types_checkbox.html b/wagtail/admin/templates/wagtailadmin/workflows/includes/workflow_content_types_checkbox.html
index 0005aaec1f..da943a5cde 100644
--- a/wagtail/admin/templates/wagtailadmin/workflows/includes/workflow_content_types_checkbox.html
+++ b/wagtail/admin/templates/wagtailadmin/workflows/includes/workflow_content_types_checkbox.html
@@ -3,7 +3,7 @@
{% for id, errors in errors_by_id.items %}
{% if id == widget.value %}
<div class="w-field__errors" data-field-errors>
- {% icon name="warning" class_name="w-field__errors-icon" %}
+ {% icon name="warning" classname="w-field__errors-icon" %}
<p class="error-message">
{% for error in errors %}{{ error.message }} {% endfor %}
</p>
diff --git a/wagtail/admin/templatetags/wagtailadmin_tags.py b/wagtail/admin/templatetags/wagtailadmin_tags.py
index fdb15c5d3c..a94d1a6f1e 100644
--- a/wagtail/admin/templatetags/wagtailadmin_tags.py
+++ b/wagtail/admin/templatetags/wagtailadmin_tags.py
@@ -764,8 +764,8 @@ def icon(name=None, classname=None, title=None, wrapped=False, class_name=None):
warn(
(
- "Icon template tag `class_name` has been renamed to `classname`, please adopt the new usage instead.",
- f'Replace `{{% icon ... class_name="{class_name}" %}}` with `{{% icon ... classname="{class_name}" %}}`',
+ "Icon template tag `class_name` has been renamed to `classname`, please adopt the new usage instead. "
+ f'Replace `{{% icon ... class_name="{class_name}" %}}` with `{{% icon ... classname="{class_name}" %}}`'
),
category=RemovedInWagtail50Warning,
)
| wagtail/wagtail | 357edf2914bfb7b1265011b1009f0d57ff9824f1 | diff --git a/wagtail/admin/tests/test_templatetags.py b/wagtail/admin/tests/test_templatetags.py
index 12aad1683a..a28c2f13ea 100644
--- a/wagtail/admin/tests/test_templatetags.py
+++ b/wagtail/admin/tests/test_templatetags.py
@@ -27,6 +27,7 @@ from wagtail.images.tests.utils import get_test_image_file
from wagtail.models import Locale
from wagtail.test.utils import WagtailTestUtils
from wagtail.users.models import UserProfile
+from wagtail.utils.deprecation import RemovedInWagtail50Warning
class TestAvatarTemplateTag(TestCase, WagtailTestUtils):
@@ -483,3 +484,62 @@ class ClassnamesTagTest(TestCase):
actual = Template(template).render(context)
self.assertEqual(expected.strip(), actual.strip())
+
+
+class IconTagTest(TestCase):
+ def test_basic(self):
+ template = """
+ {% load wagtailadmin_tags %}
+ {% icon "wagtail" %}
+ """
+
+ expected = """
+ <svg aria-hidden="true" class="icon icon-wagtail icon"><use href="#icon-wagtail"></svg>
+ """
+
+ self.assertHTMLEqual(expected, Template(template).render(Context()))
+
+ def test_with_classes_positional(self):
+ template = """
+ {% load wagtailadmin_tags %}
+ {% icon "cogs" "myclass" %}
+ """
+
+ expected = """
+ <svg aria-hidden="true" class="icon icon-cogs myclass"><use href="#icon-cogs"></svg>
+ """
+
+ self.assertHTMLEqual(expected, Template(template).render(Context()))
+
+ def test_with_classes_keyword(self):
+ template = """
+ {% load wagtailadmin_tags %}
+ {% icon "warning" classname="myclass" %}
+ """
+
+ expected = """
+ <svg aria-hidden="true" class="icon icon-warning myclass"><use href="#icon-warning"></svg>
+ """
+
+ self.assertHTMLEqual(expected, Template(template).render(Context()))
+
+ def test_with_classes_obsolete_keyword(self):
+ template = """
+ {% load wagtailadmin_tags %}
+ {% icon "doc-empty" class_name="myclass" %}
+ """
+
+ expected = """
+ <svg aria-hidden="true" class="icon icon-doc-empty myclass"><use href="#icon-doc-empty"></svg>
+ """
+
+ with self.assertWarnsMessage(
+ RemovedInWagtail50Warning,
+ (
+ "Icon template tag `class_name` has been renamed to `classname`, "
+ "please adopt the new usage instead. Replace "
+ '`{% icon ... class_name="myclass" %}` with '
+ '`{% icon ... classname="myclass" %}`'
+ ),
+ ):
+ self.assertHTMLEqual(expected, Template(template).render(Context()))
| Tests failing on latest `main`
<!--
Found a bug? Please fill out the sections below. 👍
-->
### Issue Summary
Some tests for the ~~legacy~~ moderation feature seems to be failing on latest `main` after #9817. Weirdly, they passed when the CI was run on the PR: https://github.com/wagtail/wagtail/actions/runs/3956994621
Will investigate later today.
<!--
A summary of the issue.
-->
### Steps to Reproduce
1. (for example) Start a new project with `wagtail start myproject`
2. Edit models.py as follows...
3. ...
Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?
- I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: (yes / no)
### Technical details
- Python version: Run `python --version`.
- Django version: Look in your requirements.txt, or run `pip show django | grep Version`.
- Wagtail version: Look at the bottom of the Settings menu in the Wagtail admin, or run `pip show wagtail | grep Version:`.
- Browser version: You can use https://www.whatsmybrowser.org/ to find this out.
| 0.0 | 357edf2914bfb7b1265011b1009f0d57ff9824f1 | [
"wagtail/admin/tests/test_templatetags.py::IconTagTest::test_with_classes_obsolete_keyword"
]
| [
"wagtail/admin/tests/test_templatetags.py::TestNotificationStaticTemplateTag::test_local_notification_static",
"wagtail/admin/tests/test_templatetags.py::TestNotificationStaticTemplateTag::test_local_notification_static_baseurl",
"wagtail/admin/tests/test_templatetags.py::TestNotificationStaticTemplateTag::test_remote_notification_static",
"wagtail/admin/tests/test_templatetags.py::TestVersionedStatic::test_versioned_static",
"wagtail/admin/tests/test_templatetags.py::TestVersionedStatic::test_versioned_static_absolute_path",
"wagtail/admin/tests/test_templatetags.py::TestVersionedStatic::test_versioned_static_url",
"wagtail/admin/tests/test_templatetags.py::TestVersionedStatic::test_versioned_static_version_string",
"wagtail/admin/tests/test_templatetags.py::TestTimesinceTags::test_human_readable_date",
"wagtail/admin/tests/test_templatetags.py::TestTimesinceTags::test_timesince_last_update_before_today_shows_timeago",
"wagtail/admin/tests/test_templatetags.py::TestTimesinceTags::test_timesince_last_update_today_shows_time",
"wagtail/admin/tests/test_templatetags.py::TestTimesinceTags::test_timesince_simple",
"wagtail/admin/tests/test_templatetags.py::TestComponentTag::test_component_escapes_unsafe_strings",
"wagtail/admin/tests/test_templatetags.py::TestComponentTag::test_error_on_rendering_non_component",
"wagtail/admin/tests/test_templatetags.py::TestComponentTag::test_passing_context_to_component",
"wagtail/admin/tests/test_templatetags.py::ComponentTest::test_kwargs_with_filters",
"wagtail/admin/tests/test_templatetags.py::ComponentTest::test_render_as_variable",
"wagtail/admin/tests/test_templatetags.py::ComponentTest::test_render_block_component",
"wagtail/admin/tests/test_templatetags.py::ComponentTest::test_render_nested",
"wagtail/admin/tests/test_templatetags.py::FragmentTagTest::test_basic",
"wagtail/admin/tests/test_templatetags.py::FragmentTagTest::test_syntax_error",
"wagtail/admin/tests/test_templatetags.py::FragmentTagTest::test_with_variables",
"wagtail/admin/tests/test_templatetags.py::ClassnamesTagTest::test_with_args_with_extra_whitespace",
"wagtail/admin/tests/test_templatetags.py::ClassnamesTagTest::test_with_falsy_args",
"wagtail/admin/tests/test_templatetags.py::ClassnamesTagTest::test_with_multiple_args",
"wagtail/admin/tests/test_templatetags.py::ClassnamesTagTest::test_with_single_arg",
"wagtail/admin/tests/test_templatetags.py::IconTagTest::test_basic",
"wagtail/admin/tests/test_templatetags.py::IconTagTest::test_with_classes_keyword",
"wagtail/admin/tests/test_templatetags.py::IconTagTest::test_with_classes_positional"
]
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2023-01-19 18:04:11+00:00 | bsd-3-clause | 6,220 |
|
walles__px-50 | diff --git a/px/px_loginhistory.py b/px/px_loginhistory.py
index 57c3ff8..e03fa65 100644
--- a/px/px_loginhistory.py
+++ b/px/px_loginhistory.py
@@ -11,24 +11,26 @@ import dateutil.tz
LAST_USERNAME = "([^ ]+)"
LAST_DEVICE = "([^ ]+)"
LAST_ADDRESS = "([^ ]+)?"
+LAST_PID = "( \[[0-9]+\])?"
LAST_FROM = "(... ... .. ..:..)"
LAST_DASH = " [- ] "
LAST_TO = "[^(]*"
LAST_DURATION = "([0-9+:]+)"
LAST_RE = re.compile(
- LAST_USERNAME +
- " +" +
- LAST_DEVICE +
- " +" +
- LAST_ADDRESS +
- " +" +
- LAST_FROM +
- LAST_DASH +
- LAST_TO +
- " *(\(" +
- LAST_DURATION +
- "\))?"
+ LAST_USERNAME +
+ " +" +
+ LAST_DEVICE +
+ " +" +
+ LAST_ADDRESS +
+ LAST_PID +
+ " +" +
+ LAST_FROM +
+ LAST_DASH +
+ LAST_TO +
+ " *(\(" +
+ LAST_DURATION +
+ "\))?"
)
TIMEDELTA_RE = re.compile("(([0-9]+)\+)?([0-9][0-9]):([0-9][0-9])")
@@ -89,8 +91,8 @@ def get_users_at(timestamp, last_output=None, now=None):
username = match.group(1)
address = match.group(3)
- from_s = match.group(4)
- duration_s = match.group(6)
+ from_s = match.group(5)
+ duration_s = match.group(7)
if address:
username += " from " + address
| walles/px | 809f161662aa5df0108d154435cdc3186b35bb76 | diff --git a/tests/px_loginhistory_test.py b/tests/px_loginhistory_test.py
index 191e602..ffd5019 100644
--- a/tests/px_loginhistory_test.py
+++ b/tests/px_loginhistory_test.py
@@ -289,3 +289,14 @@ def test_to_timedelta(check_output):
assert px_loginhistory._to_timedelta("01:29") == datetime.timedelta(0, hours=1, minutes=29)
assert px_loginhistory._to_timedelta("4+01:29") == datetime.timedelta(4, hours=1, minutes=29)
assert px_loginhistory._to_timedelta("34+01:29") == datetime.timedelta(34, hours=1, minutes=29)
+
+
+def test_realworld_debian(check_output):
+ """
+ Regression test for https://github.com/walles/px/issues/48
+ """
+ now = datetime.datetime(2016, 12, 6, 9, 21, tzinfo=dateutil.tz.tzlocal())
+ testtime = datetime.datetime(2016, 10, 24, 15, 34, tzinfo=dateutil.tz.tzlocal())
+ lastline = "norbert pts/3 mosh [29846] Wed Oct 24 15:33 - 15:34 (00:01)"
+
+ assert set(["norbert from mosh"]) == get_users_at(lastline, now, testtime)
| Asked to report last line: mosh
Hi,
thanks for the very useful program. I just got the following message when running `px <PID-OF-MY-SESSION>`:
```
Users logged in when cinnamon-session(2417) started:
WARNING: Please report unmatched last line at https://github.com/walles/px/issues/new: <norbert pts/3 mosh [29846] Wed Oct 24 15:33 - 15:34 (00:01)>
WARNING: Please report unmatched last line at https://github.com/walles/px/issues/new: <norbert pts/1 mosh [14332] Tue Sep 11 15:28 - 15:29 (00:01)>
norbert from :0
```
This is on Debian/unstable, `px --version` returns `0.0.0`, and the Debian package version is `1.0.13-2`. | 0.0 | 809f161662aa5df0108d154435cdc3186b35bb76 | [
"tests/px_loginhistory_test.py::test_realworld_debian"
]
| [
"tests/px_loginhistory_test.py::test_get_users_at_range",
"tests/px_loginhistory_test.py::test_get_users_at_still_logged_in",
"tests/px_loginhistory_test.py::test_get_users_at_remote",
"tests/px_loginhistory_test.py::test_get_users_at_local_osx",
"tests/px_loginhistory_test.py::test_get_users_at_local_linux",
"tests/px_loginhistory_test.py::test_get_users_at_until_crash",
"tests/px_loginhistory_test.py::test_get_users_at_until_shutdown_osx",
"tests/px_loginhistory_test.py::test_get_users_at_until_shutdown_linux",
"tests/px_loginhistory_test.py::test_get_users_at_multiple",
"tests/px_loginhistory_test.py::test_get_users_at_pseudousers_osx",
"tests/px_loginhistory_test.py::test_get_users_at_pseudousers_linux",
"tests/px_loginhistory_test.py::test_get_users_at_gone_no_logout",
"tests/px_loginhistory_test.py::test_get_users_at_trailing_noise",
"tests/px_loginhistory_test.py::test_get_users_at_unexpected_last_output",
"tests/px_loginhistory_test.py::test_get_users_at_just_run_it",
"tests/px_loginhistory_test.py::test_to_timestamp",
"tests/px_loginhistory_test.py::test_to_timedelta"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2018-12-06 09:21:17+00:00 | mit | 6,221 |
|
wandera__1password-client-16 | diff --git a/onepassword/utils.py b/onepassword/utils.py
index f37313d..733612b 100644
--- a/onepassword/utils.py
+++ b/onepassword/utils.py
@@ -1,6 +1,10 @@
import os
import base64
from Crypto.Cipher import AES
+from Crypto.Util.Padding import pad
+
+
+BLOCK_SIZE = 32 # Bytes
def read_bash_return(cmd, single=True):
@@ -128,14 +132,14 @@ class BashProfile:
class Encryption:
def __init__(self, secret_key):
- self.secret_key = secret_key[0:32]
+ self.secret_key = secret_key[0:BLOCK_SIZE]
self.cipher = AES.new(self.secret_key, AES.MODE_ECB)
def decode(self, encoded):
- return self.cipher.decrypt(base64.b64decode(encoded)).decode('UTF-8').replace(" ", "")
+ return self.cipher.decrypt(base64.b64decode(encoded)).decode('UTF-8').replace("\x1f", "")
def encode(self, input_str):
- return base64.b64encode(self.cipher.encrypt(input_str.rjust(32)))
+ return base64.b64encode(self.cipher.encrypt(pad(input_str, BLOCK_SIZE)))
def bump_version():
| wandera/1password-client | 111638ee3e05762bb3008a6d31310afee1d22f1f | diff --git a/test/test_client.py b/test/test_client.py
index f27454d..281d14f 100644
--- a/test/test_client.py
+++ b/test/test_client.py
@@ -12,7 +12,7 @@ def set_up_one_password():
domain = "test"
email = "[email protected]"
secret = "test_secret"
- password = "test_password"
+ password = "a234567890b234567890c234567890d234567890e23"
account = "test"
with open('.bash_profile', 'w') as f:
f.write("OP_SESSION_test=fakelettersforsessionkey")
| Login fails: "Data must be aligned to block boundary in ECB mode"
Hi, logging into my 1password account fails with the ValueError message above:
`from onepassword import OnePassword
op = OnePassword()
1Password master password:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/homebrew/lib/python3.9/site-packages/onepassword/client.py", line 60, in __init__
self.encrypted_master_password, self.session_key = self.signin_wrapper(master_password=password)
File "/opt/homebrew/lib/python3.9/site-packages/onepassword/client.py", line 179, in signin_wrapper
encrypted_str = encrypt.encode(password)
File "/opt/homebrew/lib/python3.9/site-packages/onepassword/utils.py", line 173, in encode
return base64.b64encode(self.cipher.encrypt(input_str.rjust(32)))
File "/opt/homebrew/lib/python3.9/site-packages/Crypto/Cipher/_mode_ecb.py", line 141, in encrypt
raise ValueError("Data must be aligned to block boundary in ECB mode")
ValueError: Data must be aligned to block boundary in ECB mode`
Python 3.9.2, op 1.8.0, 1password-client 0.3.0
Best regards, Jan | 0.0 | 111638ee3e05762bb3008a6d31310afee1d22f1f | [
"test/test_client.py::TestClient::test_delete_document",
"test/test_client.py::TestClient::test_first_use",
"test/test_client.py::TestClient::test_get_document",
"test/test_client.py::TestClient::test_get_items",
"test/test_client.py::TestClient::test_get_uuid",
"test/test_client.py::TestClient::test_list_vaults",
"test/test_client.py::TestClient::test_put_document",
"test/test_client.py::TestClient::test_signin_wrapper",
"test/test_client.py::TestClient::test_signout",
"test/test_client.py::TestClient::test_update_document"
]
| []
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2021-04-10 16:53:53+00:00 | mit | 6,222 |
|
warpnet__salt-lint-196 | diff --git a/saltlint/linter.py b/saltlint/linter.py
index 44951d9..83e12be 100644
--- a/saltlint/linter.py
+++ b/saltlint/linter.py
@@ -79,7 +79,8 @@ class RulesCollection(object):
self.config = config
def register(self, obj):
- self.rules.append(obj)
+ if not any(rule.id == obj.id for rule in self.rules):
+ self.rules.append(obj)
def __iter__(self):
return iter(self.rules)
diff --git a/saltlint/rules/JinjaVariableHasSpacesRule.py b/saltlint/rules/JinjaVariableHasSpacesRule.py
index a0c5fd8..0941753 100644
--- a/saltlint/rules/JinjaVariableHasSpacesRule.py
+++ b/saltlint/rules/JinjaVariableHasSpacesRule.py
@@ -15,7 +15,7 @@ class JinjaVariableHasSpacesRule(SaltLintRule):
tags = ['formatting', 'jinja']
version_added = 'v0.0.1'
- bracket_regex = re.compile(r"{{[^ \-\+]|{{[-\+][^ ]|[^ \-\+]}}|[^ ][-\+]}}")
+ bracket_regex = re.compile(r"{{[^ \-\+\d]|{{[-\+][^ ]|[^ \-\+\d]}}|[^ {][-\+\d]}}")
def match(self, file, line):
return self.bracket_regex.search(line)
| warpnet/salt-lint | b31433d5c8f2201c723a9c3be9b9034039a73d49 | diff --git a/tests/unit/TestJinjaVariableHasSpaces.py b/tests/unit/TestJinjaVariableHasSpaces.py
index a066818..1fd0448 100644
--- a/tests/unit/TestJinjaVariableHasSpaces.py
+++ b/tests/unit/TestJinjaVariableHasSpaces.py
@@ -18,7 +18,27 @@ BAD_VARIABLE_LINE = '''
{{-variable+}}
'''
-class TestLineTooLongRule(unittest.TestCase):
+BAD_VARIABLE_ENDING_IN_INTEGER = '''
+{{-variable0+}}
+'''
+
+BAD_VARIABLE_ENDING_IN_INTEGER_RIGHT = '''
+{{ variable0}}
+'''
+
+DOUBLE_QUOTED_INTEGER_IS_VALID = '''
+{{ "{{0}}" }}
+'''
+
+DOUBLE_QUOTED_INTEGER_TRAILING_SPACE_IS_INVALID = '''
+{{ "{{0}}"}}
+'''
+
+DOUBLE_QUOTED_INTEGER_LEADING_SPACE_IS_INVALID = '''
+{{"{{0}}" }}
+'''
+
+class TestJinjaVariableHasSpaces(unittest.TestCase):
collection = RulesCollection()
def setUp(self):
@@ -32,3 +52,23 @@ class TestLineTooLongRule(unittest.TestCase):
def test_statement_negative(self):
results = self.runner.run_state(BAD_VARIABLE_LINE)
self.assertEqual(1, len(results))
+
+ def test_double_quoted_integer(self):
+ results = self.runner.run_state(DOUBLE_QUOTED_INTEGER_IS_VALID)
+ self.assertEqual(0, len(results))
+
+ def test_double_quoted_integer_trailing_space_invalid(self):
+ results = self.runner.run_state(DOUBLE_QUOTED_INTEGER_TRAILING_SPACE_IS_INVALID)
+ self.assertEqual(1, len(results))
+
+ def test_double_quoted_integer_leading_space_invalid(self):
+ results = self.runner.run_state(DOUBLE_QUOTED_INTEGER_LEADING_SPACE_IS_INVALID)
+ self.assertEqual(1, len(results))
+
+ def test_variable_bad_ends_with_integer(self):
+ results = self.runner.run_state(BAD_VARIABLE_ENDING_IN_INTEGER)
+ self.assertEqual(1, len(results))
+
+ def test_variable_bad_ends_with_integer_right(self):
+ results = self.runner.run_state(BAD_VARIABLE_ENDING_IN_INTEGER_RIGHT)
+ self.assertEqual(1, len(results))
| String representing curly braces is incorrectly detected
**Describe the bug**
In a string with curly brace-notation for standard string formatting it is necessary to use double curly braces in order to output a pair of single curly braces.
The following snippet is an extract from a jinja file to format an ldap search pattern.
```jinja
{% set search_filter="(&({}={{0}})({}=CN={},{}))".format(string1, string2, string3, string4)) %}
```
The output should be (assuming the string contents are the same as the variable name) like so:
```python
search_filter="(&(string1={0})(string2=CN=string3,string4))"
```
However, salt-lint picks up the double braces as a jinja replacement. In this case, jinja will not replace, it formats the string as expected.
Quite a conundrum
**To Reproduce**
Use the string identified above in a `jinja` file and then run salt-lint.
**Expected behavior**
The string format to pass lint.
**Desktop (please complete the following information):**
any
| 0.0 | b31433d5c8f2201c723a9c3be9b9034039a73d49 | [
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_double_quoted_integer",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_double_quoted_integer_leading_space_invalid",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_double_quoted_integer_trailing_space_invalid",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_statement_negative",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_variable_bad_ends_with_integer",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_variable_bad_ends_with_integer_right"
]
| [
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_statement_positive"
]
| {
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2020-10-08 10:34:31+00:00 | mit | 6,223 |
|
warpnet__salt-lint-206 | diff --git a/saltlint/rules/YamlHasOctalValueRule.py b/saltlint/rules/YamlHasOctalValueRule.py
index 7633f9f..d39477c 100644
--- a/saltlint/rules/YamlHasOctalValueRule.py
+++ b/saltlint/rules/YamlHasOctalValueRule.py
@@ -15,7 +15,7 @@ class YamlHasOctalValueRule(Rule):
tags = ['formatting']
version_added = 'v0.0.6'
- bracket_regex = re.compile(r"(?<=:)\s{0,}0[0-9]{1,}\s{0,}((?={#)|(?=#)|(?=$))")
+ bracket_regex = re.compile(r"^[^:]+:\s{0,}0[0-9]{1,}\s{0,}((?={#)|(?=#)|(?=$))")
def match(self, file, line):
return self.bracket_regex.search(line)
| warpnet/salt-lint | 978978e398e4240b533b35bd80bba1403ca5e684 | diff --git a/tests/unit/TestYamlHasOctalValueRule.py b/tests/unit/TestYamlHasOctalValueRule.py
index b756031..e03fc44 100644
--- a/tests/unit/TestYamlHasOctalValueRule.py
+++ b/tests/unit/TestYamlHasOctalValueRule.py
@@ -28,6 +28,12 @@ testdirectory02:
apache_disable_default_site:
apache_site.disabled:
- name: 000-default
+
+# MAC addresses shouldn't be matched, for more information see:
+# https://github.com/warpnet/salt-lint/issues/202
+infoblox_remove_record:
+ infoblox_host_record.absent:
+ - mac: 4c:f2:d3:1b:2e:05
'''
BAD_NUMBER_STATE = '''
| Some MAC addresses trigger rule 210
First of all, thank you for this tool!
**Describe the bug**
Some MAC addresses trigger rule 210.
This is the case then the two last characters are integers.
**To Reproduce**
```sls
valid: 00:e5:e5:aa:60:69
valid2: 09:41:a2:48:d1:6f
valid3: 4c:f2:d3:1b:2e:0d
invalid: 4c:f2:d3:1b:2e:05
```
**Expected behavior**
All of the above are valid (or all MAC addresses should be encapsulated).
```sh
pip3 show salt-lint
Name: salt-lint
Version: 0.4.2
``` | 0.0 | 978978e398e4240b533b35bd80bba1403ca5e684 | [
"tests/unit/TestYamlHasOctalValueRule.py::TestYamlHasOctalValueRule::test_statement_positive"
]
| [
"tests/unit/TestYamlHasOctalValueRule.py::TestYamlHasOctalValueRule::test_statement_negative"
]
| {
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true
} | 2020-11-28 20:20:21+00:00 | mit | 6,224 |
|
warpnet__salt-lint-207 | diff --git a/README.md b/README.md
index 5a02f7e..fbc3364 100644
--- a/README.md
+++ b/README.md
@@ -164,6 +164,10 @@ Optionally override the default file selection as follows:
## List of rules
+### Formatting
+
+Disable formatting checks using `-x formatting`
+
Rule | Description
:-:|:--
[201](https://github.com/warpnet/salt-lint/wiki/201) | Trailing whitespace
@@ -180,6 +184,25 @@ Rule | Description
[212](https://github.com/warpnet/salt-lint/wiki/212) | Most files should not contain irregular spaces
[213](https://github.com/warpnet/salt-lint/wiki/213) | SaltStack recommends using `cmd.run` together with `onchanges`, rather than `cmd.wait`
+### Jinja
+
+Disable jinja checks using `-x jinja`
+
+Rule | Description
+:-:|:--
+[202](https://github.com/warpnet/salt-lint/wiki/202) | Jinja statement should have spaces before and after: `{% statement %}`
+[206](https://github.com/warpnet/salt-lint/wiki/206) | Jinja variables should have spaces before and after `{{ var_name }}`
+[209](https://github.com/warpnet/salt-lint/wiki/209) | Jinja comment should have spaces before and after: `{# comment #}`
+[211](https://github.com/warpnet/salt-lint/wiki/211) | `pillar.get` or `grains.get` should be formatted differently
+
+### Deprecations
+
+Disable deprecation checks using `-x deprecation`
+
+Rule | Description
+:-:|:--
+[901](https://github.com/warpnet/salt-lint/wiki/901) | Using the `quiet` argument with `cmd.run` is deprecated. Use `output_loglevel: quiet`
+
## False Positives: Skipping Rules
Some rules are bit of a rule of thumb. To skip a specific rule for a specific task, inside your state add `# noqa [rule_id]` at the end of the line. You can skip multiple rules via a space-separated list. Example:
diff --git a/saltlint/rules/CmdRunQuietRule.py b/saltlint/rules/CmdRunQuietRule.py
new file mode 100644
index 0000000..5dd68ce
--- /dev/null
+++ b/saltlint/rules/CmdRunQuietRule.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020 Warpnet B.V.
+
+import re
+from saltlint.linter.rule import Rule
+from saltlint.utils import get_rule_skips_from_text
+
+class CmdRunQuietRule(Rule):
+ id = '901'
+ shortdesc = 'Using the quiet argument with cmd.run is deprecated. Use output_loglevel: quiet'
+ description = 'Using the quiet argument with cmd.run is deprecated. Use output_loglevel: quiet'
+
+ severity = 'HIGH'
+ tags = ['deprecation']
+ version_added = 'develop'
+
+ regex = re.compile(r"^.+\n^\s{2}cmd\.run:(?:\n.+)+\n^\s{4}- quiet\s?.*", re.MULTILINE)
+
+ def matchtext(self, file, text):
+ results = []
+
+ for match in re.finditer(self.regex, text):
+ # Get the location of the regex match
+ start = match.start()
+ end = match.end()
+
+ # Get the line number of the last character
+ lines = text[:end].splitlines()
+ line_no = len(lines)
+
+ # Skip result if noqa for this rule ID is found in section
+ section = text[start:end]
+ if self.id in get_rule_skips_from_text(section):
+ continue
+
+ # Append the match to the results
+ results.append((line_no, lines[-1], self.shortdesc))
+
+ return results
diff --git a/saltlint/utils.py b/saltlint/utils.py
index a0334b2..dbcdf23 100644
--- a/saltlint/utils.py
+++ b/saltlint/utils.py
@@ -31,3 +31,12 @@ def get_rule_skips_from_line(line):
noqa_text = line.split('# noqa')[1]
rule_id_list = noqa_text.split()
return rule_id_list
+
+
+def get_rule_skips_from_text(text):
+ rule_id_list = []
+ for line in text.splitlines():
+ rule_id_list.extend(get_rule_skips_from_line(line))
+
+ # Return a list of unique ids
+ return list(set(rule_id_list))
| warpnet/salt-lint | 56d5a889c467808135eecd6140fa9ad7b945ecd1 | diff --git a/tests/unit/TestCmdRunQuietRule.py b/tests/unit/TestCmdRunQuietRule.py
new file mode 100644
index 0000000..ffb4c55
--- /dev/null
+++ b/tests/unit/TestCmdRunQuietRule.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020 Warpnet B.V.
+
+import unittest
+
+from saltlint.linter.collection import RulesCollection
+from saltlint.rules.CmdRunQuietRule import CmdRunQuietRule
+from tests import RunFromText
+
+
+GOOD_QUIET_STATE = '''
+getpip:
+ cmd.run:
+ - name: /usr/bin/python /usr/local/sbin/get-pip.py
+ - unless: which pip
+ - require:
+ - pkg: python
+ - file: /usr/local/sbin/get-pip.py
+ - output_loglevel: quiet
+'''
+
+BAD_QUIET_STATE = '''
+getpip:
+ cmd.run:
+ - name: /usr/bin/python /usr/local/sbin/get-pip.py
+ - unless: which pip
+ - require:
+ - pkg: python
+ - file: /usr/local/sbin/get-pip.py
+ - quiet # This is the ninth line
+
+getpip2:
+ cmd.run:
+ - name: /usr/bin/python /usr/local/sbin/get-pip.py
+ - quiet
+
+getpip3:
+ cmd.run:
+ - name: /usr/bin/python /usr/local/sbin/get-pip.py
+ - quiet # noqa: 901
+'''
+
+class TestCmdRunQuietRule(unittest.TestCase):
+ collection = RulesCollection()
+
+ def setUp(self):
+ self.collection.register(CmdRunQuietRule())
+
+ def test_statement_positive(self):
+ runner = RunFromText(self.collection)
+ results = runner.run_state(GOOD_QUIET_STATE)
+ self.assertEqual(0, len(results))
+
+ def test_statement_negative(self):
+ runner = RunFromText(self.collection)
+ results = runner.run_state(BAD_QUIET_STATE)
+ self.assertEqual(2, len(results))
+
+ # Check line numbers of the results
+ self.assertEqual(9, results[0].linenumber)
+ self.assertEqual(14, results[1].linenumber)
| Feature Request: Check cmd state deprecation
### Preface
Kindly use the [check for state.cmd deprecation](https://github.com/roaldnefs/salt-lint/pull/37) as an example of adding a check. #37 has to be merged first.
### Description
Add the possibility to check for deprecation within the [cmd state](https://docs.saltstack.com/en/latest/ref/states/all/salt.states.cmd.html)
The following options have been deprecated:
* `cmd.run:quiet` (since _version 2014.1.0_)
The following options should be used:
* `cmd.run:output_loglevel: quiet`
Example(s) of an **improperly** configured state:
```code
getpip:
cmd.run:
- name: /usr/bin/python /usr/local/sbin/get-pip.py
- unless: which pip
- require:
- pkg: python
- file: /usr/local/sbin/get-pip.py
- reload_modules: True
- quiet
```
An example of **properly** configured state:
```code
getpip:
cmd.run:
- name: /usr/bin/python /usr/local/sbin/get-pip.py
- unless: which pip
- require:
- pkg: python
- file: /usr/local/sbin/get-pip.py
- reload_modules: True
- output_loglevel: quiet
```
### Fix requirements
A fix for this issue should (at least):
* Notify the user of using a deprecated option
* Notify the user since what version the option will be or has been deprecated
* A suggestion on what option to replace it with
* Contain unit tests for the check | 0.0 | 56d5a889c467808135eecd6140fa9ad7b945ecd1 | [
"tests/unit/TestCmdRunQuietRule.py::TestCmdRunQuietRule::test_statement_negative",
"tests/unit/TestCmdRunQuietRule.py::TestCmdRunQuietRule::test_statement_positive"
]
| []
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_issue_reference",
"has_added_files",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2020-11-28 22:20:13+00:00 | mit | 6,225 |
|
warpnet__salt-lint-213 | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index fc39d25..abf935e 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -20,7 +20,7 @@ jobs:
docker:
runs-on: ubuntu-latest
- steps:
+ steps:
- name: Checkout
uses: actions/checkout@v2
- name: dockerlint
@@ -57,7 +57,7 @@ jobs:
- name: Lint with codespell
run: |
pip install codespell
- codespell --skip="./.git*"
+ codespell --skip="./.git*,./saltlint/rules/FileManagedReplaceContentRule.py"
pylint:
runs-on: ubuntu-latest
diff --git a/README.md b/README.md
index 5c2f86e..81878e2 100644
--- a/README.md
+++ b/README.md
@@ -184,6 +184,7 @@ Rule | Description
[212](https://github.com/warpnet/salt-lint/wiki/212) | Most files should not contain irregular spaces
[213](https://github.com/warpnet/salt-lint/wiki/213) | SaltStack recommends using `cmd.run` together with `onchanges`, rather than `cmd.wait`
[214](https://github.com/warpnet/salt-lint/wiki/214) | SLS file with a period in the name (besides the suffix period) can not be referenced
+[215](https://github.com/warpnet/salt-lint/wiki/215) | Using `replace: False` is required when not specifying content
### Jinja
diff --git a/saltlint/rules/FileManagedReplaceContentRule.py b/saltlint/rules/FileManagedReplaceContentRule.py
new file mode 100644
index 0000000..5eca8c3
--- /dev/null
+++ b/saltlint/rules/FileManagedReplaceContentRule.py
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020 Warpnet B.V.
+
+import re
+from saltlint.linter.rule import Rule
+from saltlint.utils import get_rule_skips_from_text
+from saltlint.utils import LANGUAGE_SLS
+
+
+class FileManagedReplaceContentRule(Rule):
+ id = '215'
+ shortdesc = "Using 'replace: False' is required when not specifying content"
+ description = "Using 'replace: False' is required when not specifying content"
+
+ severity = 'HIGH'
+ languages = [LANGUAGE_SLS]
+ tags = ['formatting']
+ version_added = 'develop'
+
+ # Find the full file.managed state
+ regex = re.compile(r"^\s{2}file\.managed:.*(?:\n\s{4}.+)*", re.MULTILINE)
+ # Regex for finding the content source option
+ regex_options= re.compile(
+ r"^\s{4}-\s(?:source:|contents:|contents_pillar:|contents_grains:|replace:\s[F|f]alse).*$",
+ re.MULTILINE
+ )
+
+ def matchtext(self, file, text):
+ results = []
+
+ # Find all file.managed states in the specified sls file
+ for match in re.finditer(self.regex, text):
+ # Continue if the file.managed state includes a content source
+ # or replace is set to False
+ if re.search(self.regex_options, match.group(0)):
+ continue
+
+ # Get the location of the regex match
+ start = match.start()
+ end = match.end()
+
+ # Get the line number of the first character
+ lines = text[:start].splitlines()
+ line_no = len(lines) + 1
+
+ # Skip result if noqa for this rule ID is found in section
+ section = text[start:end]
+ if self.id in get_rule_skips_from_text(section):
+ continue
+
+ # Append the match to the results
+ results.append((line_no, section.splitlines()[0], self.shortdesc))
+
+ return results
diff --git a/saltlint/rules/JinjaCommentHasSpacesRule.py b/saltlint/rules/JinjaCommentHasSpacesRule.py
index 7c54719..cb93f30 100644
--- a/saltlint/rules/JinjaCommentHasSpacesRule.py
+++ b/saltlint/rules/JinjaCommentHasSpacesRule.py
@@ -10,8 +10,8 @@ from saltlint.utils import LANGUAGE_JINJA, LANGUAGE_SLS
class JinjaCommentHasSpacesRule(Rule):
id = '209'
- shortdesc = 'Jinja comment should have spaces before and after: {# comment #}'
- description = 'Jinja comment should have spaces before and after: ``{# comment #}``'
+ shortdesc = "Jinja comment should have spaces before and after: '{# comment #}'"
+ description = "Jinja comment should have spaces before and after: '{# comment #}'"
severity = 'LOW'
languages = [LANGUAGE_SLS, LANGUAGE_JINJA]
tags = ['formatting', 'jinja']
diff --git a/saltlint/rules/JinjaStatementHasSpacesRule.py b/saltlint/rules/JinjaStatementHasSpacesRule.py
index 59992e9..0ef024e 100644
--- a/saltlint/rules/JinjaStatementHasSpacesRule.py
+++ b/saltlint/rules/JinjaStatementHasSpacesRule.py
@@ -10,8 +10,8 @@ from saltlint.utils import LANGUAGE_JINJA, LANGUAGE_SLS
class JinjaStatementHasSpacesRule(Rule):
id = '202'
- shortdesc = 'Jinja statement should have spaces before and after: {% statement %}'
- description = 'Jinja statement should have spaces before and after: ``{% statement %}``'
+ shortdesc = "Jinja statement should have spaces before and after: '{% statement %}'"
+ description = "Jinja statement should have spaces before and after: '{% statement %}'"
severity = 'LOW'
languages = [LANGUAGE_SLS, LANGUAGE_JINJA]
tags = ['formatting', 'jinja']
diff --git a/saltlint/rules/JinjaVariableHasSpacesRule.py b/saltlint/rules/JinjaVariableHasSpacesRule.py
index 53fd0eb..946222b 100644
--- a/saltlint/rules/JinjaVariableHasSpacesRule.py
+++ b/saltlint/rules/JinjaVariableHasSpacesRule.py
@@ -10,8 +10,8 @@ from saltlint.utils import LANGUAGE_JINJA, LANGUAGE_SLS
class JinjaVariableHasSpacesRule(Rule):
id = '206'
- shortdesc = 'Jinja variables should have spaces before and after: {{ var_name }}'
- description = 'Jinja variables should have spaces before and after: ``{{ var_name }}``'
+ shortdesc = "Jinja variables should have spaces before and after: '{{ var_name }}'"
+ description = "Jinja variables should have spaces before and after: '{{ var_name }}'"
severity = 'LOW'
languages = [LANGUAGE_SLS, LANGUAGE_JINJA]
tags = ['formatting', 'jinja']
diff --git a/saltlint/rules/YamlHasOctalValueRule.py b/saltlint/rules/YamlHasOctalValueRule.py
index 57b4f82..2001e49 100644
--- a/saltlint/rules/YamlHasOctalValueRule.py
+++ b/saltlint/rules/YamlHasOctalValueRule.py
@@ -10,8 +10,8 @@ from saltlint.utils import LANGUAGE_SLS
class YamlHasOctalValueRule(Rule):
id = '210'
- shortdesc = 'Numbers that start with `0` should always be encapsulated in quotation marks'
- description = 'Numbers that start with `0` should always be encapsulated in quotation marks'
+ shortdesc = "Numbers that start with '0' should always be encapsulated in quotation marks"
+ description = "Numbers that start with '0' should always be encapsulated in quotation marks"
severity = 'HIGH'
languages = [LANGUAGE_SLS]
tags = ['formatting']
| warpnet/salt-lint | dc836e3a7f6cfe84544e39af9a0524aca59cd3fd | diff --git a/tests/unit/TestFileManagedReplaceContentRule.py b/tests/unit/TestFileManagedReplaceContentRule.py
new file mode 100644
index 0000000..76d453e
--- /dev/null
+++ b/tests/unit/TestFileManagedReplaceContentRule.py
@@ -0,0 +1,107 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020 Warpnet B.V.
+
+import unittest
+
+from saltlint.linter.collection import RulesCollection
+from saltlint.rules.FileManagedReplaceContentRule import FileManagedReplaceContentRule
+from tests import RunFromText
+
+
+GOOD_FILE_STATE = '''
+cis_grub.cfg:
+ file.managed:
+ - name: /boot/grub.cfg
+ - user: root
+ - group: root
+ - mode: '0700'
+ - source: salt://grub/files/grub.cfg
+
+cis_systemid_only_set_once:
+ file.managed:
+ - name: /tmp/systemid
+ - user: root
+ - group: root
+ - replace: False
+ - contents_grains: osmajorrelease
+
+user:
+ user.present:
+ - name: "salt-lint"
+ file.managed:
+ - name: /user/salt-lint/.bashrc
+ - user: root
+ - group: root
+ - mode: '0700'
+ - contents_pillar: bashrc
+
+cis_grub.cfg_managerights:
+ file.managed:
+ - name: /boot/grub.cfg
+ - user: root
+ - group: root
+ - mode: '0700'
+ - replace: False
+
+cis_grub_permissions:
+ file.managed:
+ - name: /boot/grub.cfg
+ - replace: false
+ - user: root
+ - group: root
+ - mode: '0700'
+'''
+
+BAD_FILE_STATE = '''
+cis_grub.cfg:
+ file.managed:
+ - name: /boot/grub.cfg
+ - user: root
+ - group: root
+ - mode: '0700'
+
+cis_systemid_only_set_once:
+ file.managed:
+ - name: /tmp/systemid
+ - user: root
+ - group: root
+ - replace: True
+
+user:
+ user.present:
+ - name: "salt-lint"
+ file.managed:
+ - name: /user/salt-lint/.bashrc
+ - user: root
+ - group: root
+ - mode: '0700'
+
+cis_grub_permissions:
+ file.managed: # noqa: 215
+ - name: /boot/grub.cfg
+ - user: root
+ - group: root
+ - mode: '0700'
+'''
+
+
+class TestFileManagedReplaceContentRule(unittest.TestCase):
+ collection = RulesCollection()
+
+ def setUp(self):
+ self.collection.register(FileManagedReplaceContentRule())
+
+ def test_statement_positive(self):
+ runner = RunFromText(self.collection)
+ results = runner.run_state(GOOD_FILE_STATE)
+ self.assertEqual(0, len(results))
+
+ def test_statement_negative(self):
+ runner = RunFromText(self.collection)
+ results = runner.run_state(BAD_FILE_STATE)
+ self.assertEqual(3, len(results))
+
+ # Check line numbers of the results
+ self.assertEqual(3, results[0].linenumber)
+ self.assertEqual(10, results[1].linenumber)
+ self.assertEqual(19, results[2].linenumber)
| Feature Request: Add rule for cron state validation
**Is your feature request related to a problem? Please describe.**
[`cron.{present,absent}`](https://docs.saltstack.com/en/master/ref/states/all/salt.states.cron.html#salt.states.cron.present) changes include some surprising gotchas, this is because the identifier defaults to the `- name:`
```bash
identifier
Custom-defined identifier for tracking the cron line for future crontab edits. This defaults to the state name
```
Require `- identifier:` to be present for `cron.{present,absent}` states which would avoid coupling action changing from identifier changing.
**Describe the solution you'd like**
Since name defines both identifier and action by default, I'd recommend that the linter would verify that `- identifier:` was present. It would also verify that the `- identifier:` does not use any jinja templating as it's ideal that the data is not changed external the declaration.
This would make changing the actions not create duplicate crons.
**Describe alternatives you've considered**
My personal opinion is that salt shouldn't be combining the identifier for uniqueness and the command you are running, but I feel that would be a fairly large and breaking api change.
| 0.0 | dc836e3a7f6cfe84544e39af9a0524aca59cd3fd | [
"tests/unit/TestFileManagedReplaceContentRule.py::TestFileManagedReplaceContentRule::test_statement_negative",
"tests/unit/TestFileManagedReplaceContentRule.py::TestFileManagedReplaceContentRule::test_statement_positive"
]
| []
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2020-12-04 14:11:04+00:00 | mit | 6,226 |
|
warpnet__salt-lint-231 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ff9c18..ba0a0f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
All notable changes in **salt-lint** are documented below.
## [Unreleased]
+### Fixed
+- Ensure all excluded paths from both the CLI and configuration are passed to the runner ([#231](https://github.com/warpnet/salt-lint/pull/231)).
+
## [0.5.0] (2021-01-17)
### Added
- Rule 213 to recommend using cmd.run together with onchanges ([#207](https://github.com/warpnet/salt-lint/pull/207)).
diff --git a/saltlint/linter/runner.py b/saltlint/linter/runner.py
index 752d0e6..5f62e4a 100644
--- a/saltlint/linter/runner.py
+++ b/saltlint/linter/runner.py
@@ -38,7 +38,8 @@ class Runner(object):
# These will be (potentially) relative paths
paths = [path.strip() for path in exclude_paths]
self.exclude_paths = paths + [os.path.abspath(path) for path in paths]
- self.exclude_paths = []
+ else:
+ self.exclude_paths = []
def is_excluded(self, file_path):
# Any will short-circuit as soon as something returns True, but will
| warpnet/salt-lint | ab17ad972c36ceb3d91ccae0bdabebadb040e324 | diff --git a/tests/unit/TestRunner.py b/tests/unit/TestRunner.py
index b1e8e02..0d0ceb2 100644
--- a/tests/unit/TestRunner.py
+++ b/tests/unit/TestRunner.py
@@ -4,6 +4,9 @@
import unittest
from saltlint.cli import run
+from saltlint.config import Configuration
+from saltlint.linter.runner import Runner
+
class TestRunner(unittest.TestCase):
@@ -18,3 +21,16 @@ class TestRunner(unittest.TestCase):
# expected.
args = ['tests/test-extension-success.sls']
self.assertEqual(run(args), 0)
+
+ def test_runner_exclude_paths(self):
+ """
+ Check if all the excluded paths from the configuration are passed to
+ the runner.
+ """
+ exclude_paths = ['first.sls', 'second.sls']
+ config = Configuration(dict(exclude_paths=exclude_paths))
+ runner = Runner([], 'init.sls', config)
+
+ self.assertTrue(
+ any(path in runner.exclude_paths for path in exclude_paths)
+ )
| --exclude does not seem to work since 0.5.0
In my CI I have :
``` bash
find . -name "*.jinja" -o -name "*sls" | xargs --no-run-if-empty salt-lint -x 204,205 --exclude ./common_syslog-ng.sls
```
So I was not notified on lint errors for `common_syslog-ng.sls` file, but since 0.5.0 version I get errors from this file.
If I set image tag to `0.4.2`, normal behaviour is back.
| 0.0 | ab17ad972c36ceb3d91ccae0bdabebadb040e324 | [
"tests/unit/TestRunner.py::TestRunner::test_runner_exclude_paths"
]
| [
"tests/unit/TestRunner.py::TestRunner::test_runner_with_matches",
"tests/unit/TestRunner.py::TestRunner::test_runner_without_matches"
]
| {
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false
} | 2021-01-19 18:24:18+00:00 | mit | 6,227 |
|
warpnet__salt-lint-236 | diff --git a/CHANGELOG.md b/CHANGELOG.md
index 82eff64..7d78e56 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ All notable changes in **salt-lint** are documented below.
## [Unreleased]
### Fixed
- Append the contents of the `CHANGELOG.md` file to the long description of the package instead of the duplicate `README.md` contents ([#234](https://github.com/warpnet/salt-lint/pull/234)).
+- Ignore Jinja specific rules in Jinja escaped blocks ([#236](https://github.com/warpnet/salt-lint/pull/236)).
## [0.5.1] (2021-01-19)
### Fixed
diff --git a/saltlint/linter/rule.py b/saltlint/linter/rule.py
index e006699..fc3fded 100644
--- a/saltlint/linter/rule.py
+++ b/saltlint/linter/rule.py
@@ -7,7 +7,7 @@ import six
from saltlint.utils import get_rule_skips_from_line, get_file_type
from saltlint.linter.match import Match
-from saltlint.utils import LANGUAGE_SLS
+from saltlint.utils import LANGUAGE_SLS, LANGUAGE_JINJA
class Rule(object):
@@ -89,6 +89,44 @@ class Rule(object):
return matches
+class JinjaRule(Rule):
+ languages = [LANGUAGE_SLS, LANGUAGE_JINJA]
+ tags = ['formatting', 'jinja']
+
+ # Regex for matching all escaped Jinja blocks in the text
+ jinja_escape_regex = re.compile(
+ r"{%[+-]?\s?raw\s?[+-]?%}.*{%[+-]?\s?endraw\s?[+-]?%}",
+ re.DOTALL | re.MULTILINE
+ )
+
+ def matchlines(self, file, text):
+ """
+ Match the text line by line but ignore all escaped Jinja blocks, e.g.
+ content between {% raw %} and {% endraw %}.
+
+ Returns a list of Match objects.
+ """
+ escaped_text = text
+ # Replace escaped Jinja blocks with the same number of empty lines
+ for match in self.jinja_escape_regex.finditer(text):
+ start = match.start()
+ end = match.end()
+ # Get the number of newlines in the escaped match
+ lines = text[start:end].splitlines()
+ num_of_lines = len(lines) - 1
+
+ # Replace escaped Jinja block in the escaped text by newlines to
+ # keep all the line numbers consistent
+ pre_text = escaped_text[:start]
+ post_text = escaped_text[end:]
+ newlines = '\n' * num_of_lines
+ escaped_text = pre_text + newlines + post_text
+
+ # Call the matchlines() on the parent class with the escaped text
+ matches = super(JinjaRule, self).matchlines(file, escaped_text) # pylint: disable=R1725
+ return matches
+
+
class DeprecationRule(Rule):
id = None
state = None
diff --git a/saltlint/rules/JinjaCommentHasSpacesRule.py b/saltlint/rules/JinjaCommentHasSpacesRule.py
index cb93f30..ce61646 100644
--- a/saltlint/rules/JinjaCommentHasSpacesRule.py
+++ b/saltlint/rules/JinjaCommentHasSpacesRule.py
@@ -1,20 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Will Thames and contributors
# Copyright (c) 2018 Ansible Project
-# Modified work Copyright (c) 2020 Warpnet B.V.
+# Modified work Copyright (c) 2020-2021 Warpnet B.V.
import re
-from saltlint.linter.rule import Rule
-from saltlint.utils import LANGUAGE_JINJA, LANGUAGE_SLS
+from saltlint.linter.rule import JinjaRule
-class JinjaCommentHasSpacesRule(Rule):
+class JinjaCommentHasSpacesRule(JinjaRule):
id = '209'
shortdesc = "Jinja comment should have spaces before and after: '{# comment #}'"
description = "Jinja comment should have spaces before and after: '{# comment #}'"
severity = 'LOW'
- languages = [LANGUAGE_SLS, LANGUAGE_JINJA]
- tags = ['formatting', 'jinja']
version_added = 'v0.0.5'
bracket_regex = re.compile(r"{#[^ \-\+]|{#[\-\+][^ ]|[^ \-\+]#}|[^ ][\-\+]#}")
diff --git a/saltlint/rules/JinjaPillarGrainsGetFormatRule.py b/saltlint/rules/JinjaPillarGrainsGetFormatRule.py
index accace3..8b53c5e 100644
--- a/saltlint/rules/JinjaPillarGrainsGetFormatRule.py
+++ b/saltlint/rules/JinjaPillarGrainsGetFormatRule.py
@@ -1,22 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Will Thames and contributors
# Copyright (c) 2018 Ansible Project
-# Modified work Copyright (c) 2020 Warpnet B.V.
+# Modified work Copyright (c) 2020-2021 Warpnet B.V.
import re
-from saltlint.linter.rule import Rule
-from saltlint.utils import LANGUAGE_JINJA, LANGUAGE_SLS
+from saltlint.linter.rule import JinjaRule
-class JinjaPillarGrainsGetFormatRule(Rule):
+class JinjaPillarGrainsGetFormatRule(JinjaRule):
id = '211'
shortdesc = 'pillar.get or grains.get should be formatted differently'
description = "pillar.get and grains.get should always be formatted " \
"like salt['pillar.get']('item'), grains['item1'] or " \
" pillar.get('item')"
severity = 'HIGH'
- languages = [LANGUAGE_SLS, LANGUAGE_JINJA]
- tags = ['formatting', 'jinja']
version_added = 'v0.0.10'
bracket_regex = re.compile(r"{{( |\-|\+)?.(pillar|grains).get\[.+}}")
diff --git a/saltlint/rules/JinjaStatementHasSpacesRule.py b/saltlint/rules/JinjaStatementHasSpacesRule.py
index 0ef024e..696f591 100644
--- a/saltlint/rules/JinjaStatementHasSpacesRule.py
+++ b/saltlint/rules/JinjaStatementHasSpacesRule.py
@@ -1,20 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Will Thames and contributors
# Copyright (c) 2018 Ansible Project
-# Modified work Copyright (c) 2020 Warpnet B.V.
+# Modified work Copyright (c) 2020-2021 Warpnet B.V.
import re
-from saltlint.linter.rule import Rule
-from saltlint.utils import LANGUAGE_JINJA, LANGUAGE_SLS
+from saltlint.linter.rule import JinjaRule
-class JinjaStatementHasSpacesRule(Rule):
+class JinjaStatementHasSpacesRule(JinjaRule):
id = '202'
shortdesc = "Jinja statement should have spaces before and after: '{% statement %}'"
description = "Jinja statement should have spaces before and after: '{% statement %}'"
severity = 'LOW'
- languages = [LANGUAGE_SLS, LANGUAGE_JINJA]
- tags = ['formatting', 'jinja']
version_added = 'v0.0.2'
bracket_regex = re.compile(r"{%[^ \-\+]|{%[\-\+][^ ]|[^ \-\+]%}|[^ ][\-\+]%}")
diff --git a/saltlint/rules/JinjaVariableHasSpacesRule.py b/saltlint/rules/JinjaVariableHasSpacesRule.py
index 946222b..03433b6 100644
--- a/saltlint/rules/JinjaVariableHasSpacesRule.py
+++ b/saltlint/rules/JinjaVariableHasSpacesRule.py
@@ -1,20 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2016 Will Thames and contributors
# Copyright (c) 2018 Ansible Project
-# Modified work Copyright (c) 2020 Warpnet B.V.
+# Modified work Copyright (c) 2020-2021 Warpnet B.V.
import re
-from saltlint.linter.rule import Rule
-from saltlint.utils import LANGUAGE_JINJA, LANGUAGE_SLS
+from saltlint.linter.rule import JinjaRule
-class JinjaVariableHasSpacesRule(Rule):
+class JinjaVariableHasSpacesRule(JinjaRule):
id = '206'
shortdesc = "Jinja variables should have spaces before and after: '{{ var_name }}'"
description = "Jinja variables should have spaces before and after: '{{ var_name }}'"
severity = 'LOW'
- languages = [LANGUAGE_SLS, LANGUAGE_JINJA]
- tags = ['formatting', 'jinja']
version_added = 'v0.0.1'
bracket_regex = re.compile(r"{{[^ \-\+\d]|{{[-\+][^ ]|[^ \-\+\d]}}|[^ {][-\+\d]}}")
| warpnet/salt-lint | 05dc6f2e1d3da6ffe7d6526bf88193cec6f09f51 | diff --git a/tests/unit/TestJinjaCommentHasSpaces.py b/tests/unit/TestJinjaCommentHasSpaces.py
index 60796fe..ea5e59e 100644
--- a/tests/unit/TestJinjaCommentHasSpaces.py
+++ b/tests/unit/TestJinjaCommentHasSpaces.py
@@ -12,6 +12,12 @@ from tests import RunFromText
GOOD_COMMENT_LINE = '''
{#- set example='good' +#}
+
+{% raw %}
+ # The following line should be ignored as it is placed in a Jinja escape
+ # block
+ {#-set example='bad'+#}
+{% endraw %}
'''
BAD_COMMENT_LINE = '''
diff --git a/tests/unit/TestJinjaStatementHasSpaces.py b/tests/unit/TestJinjaStatementHasSpaces.py
index 947a876..f1534f6 100644
--- a/tests/unit/TestJinjaStatementHasSpaces.py
+++ b/tests/unit/TestJinjaStatementHasSpaces.py
@@ -12,6 +12,12 @@ from tests import RunFromText
GOOD_STATEMENT_LINE = '''
{%- set example='good' +%}
+
+{% raw %}
+ # The following line should be ignored as it is placed in a Jinja escape
+ # block
+ {%-set example='bad'+%}
+{% endraw %}
'''
BAD_STATEMENT_LINE = '''
diff --git a/tests/unit/TestJinjaVariableHasSpaces.py b/tests/unit/TestJinjaVariableHasSpaces.py
index 301cb8d..4e53f33 100644
--- a/tests/unit/TestJinjaVariableHasSpaces.py
+++ b/tests/unit/TestJinjaVariableHasSpaces.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013-2018 Will Thames <[email protected]>
# Copyright (c) 2018 Ansible by Red Hat
-# Modified work Copyright (c) 2020 Warpnet B.V.
+# Modified work Copyright (c) 2020-2021 Warpnet B.V.
import unittest
@@ -14,6 +14,19 @@ GOOD_VARIABLE_LINE = '''
{{- variable +}}
'''
+GOOD_VARIABLE_LINE_RAW = '''
+{% raw %}
+{{variable}}
+{% endraw %}
+'''
+
+BAD_VARIABLE_LINE_RAW = '''
+{% raw %}
+{{variable}}
+{% endraw %}
+{{variable}} # line 5
+'''
+
BAD_VARIABLE_LINE = '''
{{-variable+}}
'''
@@ -49,6 +62,19 @@ class TestJinjaVariableHasSpaces(unittest.TestCase):
results = self.runner.run_state(GOOD_VARIABLE_LINE)
self.assertEqual(0, len(results))
+ def test_statement_jinja_raw_positive(self):
+ """Check if Jinja looking variables between raw-blocks are ignored."""
+ results = self.runner.run_state(GOOD_VARIABLE_LINE_RAW)
+ self.assertEqual(0, len(results))
+
+ def test_statement_jinja_raw_negative(self):
+ """Check if Jinja looking variables between raw-blocks are ignored."""
+ results = self.runner.run_state(BAD_VARIABLE_LINE_RAW)
+ # Check if the correct number of matches are found
+ self.assertEqual(1, len(results))
+ # Check if the match occurred on the correct line
+ self.assertEqual(results[0].linenumber, 5)
+
def test_statement_negative(self):
results = self.runner.run_state(BAD_VARIABLE_LINE)
self.assertEqual(1, len(results))
| Errors 202, 206 and 209 triggered inside raw blocks {% raw %}/{% endraw %}
**Describe the bug**
While implementing CI using salt-lint on a Salt repo, I stumbled upon the following behavior, where errors were reported even inside raw blocks delimited by `{% raw %}`/`{% endraw %}`.
**To Reproduce**
```bash
cat > test.sls <<EOF
environments:
variables:
heketi:
{% raw %}
HEKETI_CLI_SERVER: \$(kubectl --kubeconfig=/etc/kubernetes/admin.conf get svc/heketi -n glusterfs --template "http://{{.spec.clusterIP}}:{{(index .spec.ports 0).port}}" 2>/dev/null || echo 'Go root!')
{% endraw %}
EOF
docker run --rm -v "$PWD":/data:ro -it warpnetbv/salt-lint:0.4.2 -x 204 test.sls
```
Result
```
[206] Jinja variables should have spaces before and after: {{ var_name }}
test.sls:5
HEKETI_CLI_SERVER: $(kubectl --kubeconfig=/etc/kubernetes/admin.conf get svc/heketi -n glusterfs --template "http://{{.spec.clusterIP}}:{{(index .spec.ports 0).port}}" 2>/dev/null || echo 'Go root!')
```
**Expected behavior**
Errors shouldn't be reported inside `raw` elements, or at least the ones about Jinja formatting (202, 206 and 209) should be ignored. Inside a raw block, we are not evaluating Jinja markup, so we don't care if some `{{` is not properly spaced (in fact, the raw block is meant to prevent errors during Jinja rendering by Salt as it would be interpreted as an undefined variable).
**Desktop:**
- OS: Debian 9 amd64
- Version 0.4.2
| 0.0 | 05dc6f2e1d3da6ffe7d6526bf88193cec6f09f51 | [
"tests/unit/TestJinjaCommentHasSpaces.py::TestJinjaCommentHasSpaces::test_comment_positive",
"tests/unit/TestJinjaStatementHasSpaces.py::TestLineTooLongRule::test_statement_positive",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_statement_jinja_raw_negative",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_statement_jinja_raw_positive"
]
| [
"tests/unit/TestJinjaCommentHasSpaces.py::TestJinjaCommentHasSpaces::test_comment_negative",
"tests/unit/TestJinjaStatementHasSpaces.py::TestLineTooLongRule::test_statement_negative",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_double_quoted_integer",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_double_quoted_integer_leading_space_invalid",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_double_quoted_integer_trailing_space_invalid",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_statement_negative",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_statement_positive",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_variable_bad_ends_with_integer",
"tests/unit/TestJinjaVariableHasSpaces.py::TestJinjaVariableHasSpaces::test_variable_bad_ends_with_integer_right"
]
| {
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-01-29 14:46:45+00:00 | mit | 6,228 |
|
wbond__asn1crypto-240 | diff --git a/asn1crypto/algos.py b/asn1crypto/algos.py
index fc25e4d..b7d406c 100644
--- a/asn1crypto/algos.py
+++ b/asn1crypto/algos.py
@@ -245,17 +245,29 @@ class SignedDigestAlgorithmId(ObjectIdentifier):
'1.2.840.10040.4.3': 'sha1_dsa',
'1.3.14.3.2.13': 'sha1_dsa',
'1.3.14.3.2.27': 'sha1_dsa',
+ # Source: NIST CSOR Algorithm Registrations
'2.16.840.1.101.3.4.3.1': 'sha224_dsa',
'2.16.840.1.101.3.4.3.2': 'sha256_dsa',
+ '2.16.840.1.101.3.4.3.3': 'sha384_dsa',
+ '2.16.840.1.101.3.4.3.4': 'sha512_dsa',
'1.2.840.10045.4.1': 'sha1_ecdsa',
'1.2.840.10045.4.3.1': 'sha224_ecdsa',
'1.2.840.10045.4.3.2': 'sha256_ecdsa',
'1.2.840.10045.4.3.3': 'sha384_ecdsa',
'1.2.840.10045.4.3.4': 'sha512_ecdsa',
+ # Source: NIST CSOR Algorithm Registrations
+ '2.16.840.1.101.3.4.3.5': 'sha3_224_dsa',
+ '2.16.840.1.101.3.4.3.6': 'sha3_256_dsa',
+ '2.16.840.1.101.3.4.3.7': 'sha3_384_dsa',
+ '2.16.840.1.101.3.4.3.8': 'sha3_512_dsa',
'2.16.840.1.101.3.4.3.9': 'sha3_224_ecdsa',
'2.16.840.1.101.3.4.3.10': 'sha3_256_ecdsa',
'2.16.840.1.101.3.4.3.11': 'sha3_384_ecdsa',
'2.16.840.1.101.3.4.3.12': 'sha3_512_ecdsa',
+ '2.16.840.1.101.3.4.3.13': 'sha3_224_rsa',
+ '2.16.840.1.101.3.4.3.14': 'sha3_256_rsa',
+ '2.16.840.1.101.3.4.3.15': 'sha3_384_rsa',
+ '2.16.840.1.101.3.4.3.16': 'sha3_512_rsa',
# For when the digest is specified elsewhere in a Sequence
'1.2.840.113549.1.1.1': 'rsassa_pkcs1v15',
'1.2.840.10040.4.1': 'dsa',
@@ -281,14 +293,25 @@ class SignedDigestAlgorithmId(ObjectIdentifier):
'sha256_dsa': '2.16.840.1.101.3.4.3.2',
'sha256_ecdsa': '1.2.840.10045.4.3.2',
'sha256_rsa': '1.2.840.113549.1.1.11',
+ 'sha384_dsa': '2.16.840.1.101.3.4.3.3',
'sha384_ecdsa': '1.2.840.10045.4.3.3',
'sha384_rsa': '1.2.840.113549.1.1.12',
+ 'sha512_dsa': '2.16.840.1.101.3.4.3.4',
'sha512_ecdsa': '1.2.840.10045.4.3.4',
'sha512_rsa': '1.2.840.113549.1.1.13',
+ # Source: NIST CSOR Algorithm Registrations
+ 'sha3_224_dsa': '2.16.840.1.101.3.4.3.5',
+ 'sha3_256_dsa': '2.16.840.1.101.3.4.3.6',
+ 'sha3_384_dsa': '2.16.840.1.101.3.4.3.7',
+ 'sha3_512_dsa': '2.16.840.1.101.3.4.3.8',
'sha3_224_ecdsa': '2.16.840.1.101.3.4.3.9',
'sha3_256_ecdsa': '2.16.840.1.101.3.4.3.10',
'sha3_384_ecdsa': '2.16.840.1.101.3.4.3.11',
'sha3_512_ecdsa': '2.16.840.1.101.3.4.3.12',
+ 'sha3_224_rsa': '2.16.840.1.101.3.4.3.13',
+ 'sha3_256_rsa': '2.16.840.1.101.3.4.3.14',
+ 'sha3_384_rsa': '2.16.840.1.101.3.4.3.15',
+ 'sha3_512_rsa': '2.16.840.1.101.3.4.3.16',
'ed25519': '1.3.101.112',
'ed448': '1.3.101.113',
}
@@ -323,11 +346,21 @@ class SignedDigestAlgorithm(_ForceNullParameters, Sequence):
'sha256_rsa': 'rsassa_pkcs1v15',
'sha384_rsa': 'rsassa_pkcs1v15',
'sha512_rsa': 'rsassa_pkcs1v15',
+ 'sha3_224_rsa': 'rsassa_pkcs1v15',
+ 'sha3_256_rsa': 'rsassa_pkcs1v15',
+ 'sha3_384_rsa': 'rsassa_pkcs1v15',
+ 'sha3_512_rsa': 'rsassa_pkcs1v15',
'rsassa_pkcs1v15': 'rsassa_pkcs1v15',
'rsassa_pss': 'rsassa_pss',
'sha1_dsa': 'dsa',
'sha224_dsa': 'dsa',
'sha256_dsa': 'dsa',
+ 'sha384_dsa': 'dsa',
+ 'sha512_dsa': 'dsa',
+ 'sha3_224_dsa': 'dsa',
+ 'sha3_256_dsa': 'dsa',
+ 'sha3_384_dsa': 'dsa',
+ 'sha3_512_dsa': 'dsa',
'dsa': 'dsa',
'sha1_ecdsa': 'ecdsa',
'sha224_ecdsa': 'ecdsa',
@@ -373,11 +406,25 @@ class SignedDigestAlgorithm(_ForceNullParameters, Sequence):
'sha1_dsa': 'sha1',
'sha224_dsa': 'sha224',
'sha256_dsa': 'sha256',
+ 'sha384_dsa': 'sha384',
+ 'sha512_dsa': 'sha512',
'sha1_ecdsa': 'sha1',
'sha224_ecdsa': 'sha224',
'sha256_ecdsa': 'sha256',
'sha384_ecdsa': 'sha384',
'sha512_ecdsa': 'sha512',
+ 'sha3_224_dsa': 'sha3_224',
+ 'sha3_256_dsa': 'sha3_256',
+ 'sha3_384_dsa': 'sha3_384',
+ 'sha3_512_dsa': 'sha3_512',
+ 'sha3_224_ecdsa': 'sha3_224',
+ 'sha3_256_ecdsa': 'sha3_256',
+ 'sha3_384_ecdsa': 'sha3_384',
+ 'sha3_512_ecdsa': 'sha3_512',
+ 'sha3_224_rsa': 'sha3_224',
+ 'sha3_256_rsa': 'sha3_256',
+ 'sha3_384_rsa': 'sha3_384',
+ 'sha3_512_rsa': 'sha3_512',
'ed25519': 'sha512',
'ed448': 'shake256',
}
diff --git a/asn1crypto/core.py b/asn1crypto/core.py
index 364c6b5..2edd4f3 100644
--- a/asn1crypto/core.py
+++ b/asn1crypto/core.py
@@ -166,6 +166,15 @@ def load(encoded_data, strict=False):
return Asn1Value.load(encoded_data, strict=strict)
+def unpickle_helper(asn1crypto_cls, der_bytes):
+ """
+ Helper function to integrate with pickle.
+
+ Note that this must be an importable top-level function.
+ """
+ return asn1crypto_cls.load(der_bytes)
+
+
class Asn1Value(object):
"""
The basis of all ASN.1 values
@@ -481,6 +490,12 @@ class Asn1Value(object):
return self.__repr__()
+ def __reduce__(self):
+ """
+ Permits pickling Asn1Value objects using their DER representation.
+ """
+ return unpickle_helper, (self.__class__, self.dump())
+
def _new_instance(self):
"""
Constructs a new copy of the current object, preserving any tagging
| wbond/asn1crypto | b5f03e6f9797c691a3b812a5bb1acade3a1f4eeb | diff --git a/tests/test_algos.py b/tests/test_algos.py
index 88e8cbf..064aad5 100644
--- a/tests/test_algos.py
+++ b/tests/test_algos.py
@@ -6,6 +6,8 @@ import sys
import os
from asn1crypto import algos, core
+
+from .unittest_data import data_decorator, data
from ._unittest_compat import patch
patch()
@@ -22,6 +24,7 @@ tests_root = os.path.dirname(__file__)
fixtures_dir = os.path.join(tests_root, 'fixtures')
+@data_decorator
class AlgoTests(unittest.TestCase):
def test_signed_digest_parameters(self):
@@ -78,3 +81,31 @@ class AlgoTests(unittest.TestCase):
params = algo["parameters"]
self.assertEqual(params["version"].native, 'v1-0')
self.assertEqual(params["rounds"].native, 42)
+
+ @staticmethod
+ def sha3_algo_pairs():
+ return [
+ ('sha3_224_dsa', 'sha3_224', 'dsa'),
+ ('sha3_256_dsa', 'sha3_256', 'dsa'),
+ ('sha3_384_dsa', 'sha3_384', 'dsa'),
+ ('sha3_512_dsa', 'sha3_512', 'dsa'),
+ ('sha3_224_ecdsa', 'sha3_224', 'ecdsa'),
+ ('sha3_256_ecdsa', 'sha3_256', 'ecdsa'),
+ ('sha3_384_ecdsa', 'sha3_384', 'ecdsa'),
+ ('sha3_512_ecdsa', 'sha3_512', 'ecdsa'),
+ ('sha3_224_rsa', 'sha3_224', 'rsa'),
+ ('sha3_256_rsa', 'sha3_256', 'rsa'),
+ ('sha3_384_rsa', 'sha3_384', 'rsa'),
+ ('sha3_512_rsa', 'sha3_512', 'rsa'),
+ ]
+
+ @data('sha3_algo_pairs', True)
+ def sha3_algos_round_trip(self, digest_alg, sig_alg):
+ alg_name = "%s_%s" % (digest_alg, sig_alg)
+ original = algos.SignedDigestAlgorithm({'algorithm': alg_name})
+ parsed = algos.SignedDigestAlgorithm.load(original.dump())
+ self.assertEqual(parsed.hash_algo, digest_alg)
+ self.assertEqual(
+ parsed.signature_algo,
+ 'rsassa_pkcs1v15' if sig_alg == 'rsa' else sig_alg
+ )
diff --git a/tests/test_core.py b/tests/test_core.py
index 7ac9196..fabb675 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1,6 +1,7 @@
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
+import pickle
import unittest
import os
from datetime import datetime, timedelta
@@ -1375,3 +1376,11 @@ class CoreTests(unittest.TestCase):
with self.assertRaisesRegex(ValueError, "Second arc must be "):
core.ObjectIdentifier("0.40")
+
+ def test_pickle_integration(self):
+ orig = Seq({'id': '2.3.4', 'value': b"\xde\xad\xbe\xef"})
+ pickled_bytes = pickle.dumps(orig)
+ # ensure that our custom pickling implementation was used
+ self.assertIn(b"unpickle_helper", pickled_bytes)
+ unpickled = pickle.loads(pickled_bytes)
+ self.assertEqual(orig.native, unpickled.native)
| Can asn1crypto support pickle!
Whether asn1crypto supports serialization and deserialization with files. I found that it could not work normally after being serialized and saved to a file. It was not in the same memory twice.
[https://github.com/MatthiasValvekens/pyHanko/discussions/154](interrupted_signing) | 0.0 | b5f03e6f9797c691a3b812a5bb1acade3a1f4eeb | [
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_224_dsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_224_ecdsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_224_rsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_256_dsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_256_ecdsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_256_rsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_384_dsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_384_ecdsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_384_rsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_512_dsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_512_ecdsa",
"tests/test_algos.py::AlgoTests::test_sha3_algos_round_trip_sha3_512_rsa",
"tests/test_core.py::CoreTests::test_pickle_integration"
]
| [
"tests/test_algos.py::AlgoTests::test_ccm_parameters",
"tests/test_algos.py::AlgoTests::test_digest_parameters",
"tests/test_algos.py::AlgoTests::test_rc2_parameters",
"tests/test_algos.py::AlgoTests::test_rc5_parameters",
"tests/test_algos.py::AlgoTests::test_scrypt_parameters",
"tests/test_algos.py::AlgoTests::test_signed_digest_parameters",
"tests/test_core.py::CoreTests::test_add_to_end_sequence_value",
"tests/test_core.py::CoreTests::test_bit_string_1",
"tests/test_core.py::CoreTests::test_bit_string_2",
"tests/test_core.py::CoreTests::test_bit_string_3",
"tests/test_core.py::CoreTests::test_bit_string_4",
"tests/test_core.py::CoreTests::test_bit_string_errors_1",
"tests/test_core.py::CoreTests::test_bit_string_errors_2",
"tests/test_core.py::CoreTests::test_bit_string_errors_3",
"tests/test_core.py::CoreTests::test_bit_string_item_access",
"tests/test_core.py::CoreTests::test_bit_string_load_dump",
"tests/test_core.py::CoreTests::test_broken_object_identifier",
"tests/test_core.py::CoreTests::test_cast",
"tests/test_core.py::CoreTests::test_choice_dict_name",
"tests/test_core.py::CoreTests::test_choice_dump_header_native",
"tests/test_core.py::CoreTests::test_choice_parse_return",
"tests/test_core.py::CoreTests::test_choice_tuple_name",
"tests/test_core.py::CoreTests::test_compare_primitive_1",
"tests/test_core.py::CoreTests::test_compare_primitive_10",
"tests/test_core.py::CoreTests::test_compare_primitive_11",
"tests/test_core.py::CoreTests::test_compare_primitive_12",
"tests/test_core.py::CoreTests::test_compare_primitive_13",
"tests/test_core.py::CoreTests::test_compare_primitive_2",
"tests/test_core.py::CoreTests::test_compare_primitive_3",
"tests/test_core.py::CoreTests::test_compare_primitive_4",
"tests/test_core.py::CoreTests::test_compare_primitive_5",
"tests/test_core.py::CoreTests::test_compare_primitive_6",
"tests/test_core.py::CoreTests::test_compare_primitive_7",
"tests/test_core.py::CoreTests::test_compare_primitive_8",
"tests/test_core.py::CoreTests::test_compare_primitive_9",
"tests/test_core.py::CoreTests::test_concat",
"tests/test_core.py::CoreTests::test_copy",
"tests/test_core.py::CoreTests::test_copy_choice_mutate",
"tests/test_core.py::CoreTests::test_copy_indefinite",
"tests/test_core.py::CoreTests::test_copy_mutable",
"tests/test_core.py::CoreTests::test_delete_sequence_value",
"tests/test_core.py::CoreTests::test_dump_ber_indefinite",
"tests/test_core.py::CoreTests::test_dump_set",
"tests/test_core.py::CoreTests::test_dump_set_of",
"tests/test_core.py::CoreTests::test_explicit_application_tag",
"tests/test_core.py::CoreTests::test_explicit_application_tag_nested",
"tests/test_core.py::CoreTests::test_explicit_field_default",
"tests/test_core.py::CoreTests::test_explicit_header_field_choice",
"tests/test_core.py::CoreTests::test_explicit_tag_header",
"tests/test_core.py::CoreTests::test_fix_tagging_choice",
"tests/test_core.py::CoreTests::test_force_dump_unknown_sequence",
"tests/test_core.py::CoreTests::test_generalized_time_1",
"tests/test_core.py::CoreTests::test_generalized_time_10",
"tests/test_core.py::CoreTests::test_generalized_time_2",
"tests/test_core.py::CoreTests::test_generalized_time_3",
"tests/test_core.py::CoreTests::test_generalized_time_4",
"tests/test_core.py::CoreTests::test_generalized_time_5",
"tests/test_core.py::CoreTests::test_generalized_time_6",
"tests/test_core.py::CoreTests::test_generalized_time_7",
"tests/test_core.py::CoreTests::test_generalized_time_8",
"tests/test_core.py::CoreTests::test_generalized_time_9",
"tests/test_core.py::CoreTests::test_get_sequence_value",
"tests/test_core.py::CoreTests::test_indefinite_length_bit_string",
"tests/test_core.py::CoreTests::test_indefinite_length_integer_bit_string",
"tests/test_core.py::CoreTests::test_indefinite_length_integer_octet_string",
"tests/test_core.py::CoreTests::test_indefinite_length_octet_bit_string",
"tests/test_core.py::CoreTests::test_indefinite_length_octet_string",
"tests/test_core.py::CoreTests::test_indefinite_length_octet_string_2",
"tests/test_core.py::CoreTests::test_indefinite_length_parsable_octet_bit_string",
"tests/test_core.py::CoreTests::test_indefinite_length_parsable_octet_string",
"tests/test_core.py::CoreTests::test_indefinite_length_utf8string",
"tests/test_core.py::CoreTests::test_int_to_bit_tuple",
"tests/test_core.py::CoreTests::test_integer_1",
"tests/test_core.py::CoreTests::test_integer_2",
"tests/test_core.py::CoreTests::test_integer_3",
"tests/test_core.py::CoreTests::test_integer_4",
"tests/test_core.py::CoreTests::test_integer_5",
"tests/test_core.py::CoreTests::test_integer_6",
"tests/test_core.py::CoreTests::test_integer_7",
"tests/test_core.py::CoreTests::test_integer_8",
"tests/test_core.py::CoreTests::test_integer_9",
"tests/test_core.py::CoreTests::test_integer_bit_string",
"tests/test_core.py::CoreTests::test_integer_bit_string_errors_1",
"tests/test_core.py::CoreTests::test_integer_bit_string_errors_2",
"tests/test_core.py::CoreTests::test_integer_bit_string_errors_3",
"tests/test_core.py::CoreTests::test_integer_octet_string",
"tests/test_core.py::CoreTests::test_integer_octet_string_encoded_width",
"tests/test_core.py::CoreTests::test_large_tag_encode",
"tests/test_core.py::CoreTests::test_load",
"tests/test_core.py::CoreTests::test_load_invalid_choice",
"tests/test_core.py::CoreTests::test_load_wrong_type",
"tests/test_core.py::CoreTests::test_manual_construction",
"tests/test_core.py::CoreTests::test_mapped_bit_string_1",
"tests/test_core.py::CoreTests::test_mapped_bit_string_2",
"tests/test_core.py::CoreTests::test_mapped_bit_string_3",
"tests/test_core.py::CoreTests::test_mapped_bit_string_item_access",
"tests/test_core.py::CoreTests::test_mapped_bit_string_numeric",
"tests/test_core.py::CoreTests::test_mapped_bit_string_sparse",
"tests/test_core.py::CoreTests::test_mapped_bit_string_unset_bit",
"tests/test_core.py::CoreTests::test_nested_explicit_tag_choice",
"tests/test_core.py::CoreTests::test_nested_indefinite_length_octet_string",
"tests/test_core.py::CoreTests::test_object_identifier_1",
"tests/test_core.py::CoreTests::test_object_identifier_2",
"tests/test_core.py::CoreTests::test_object_identifier_3",
"tests/test_core.py::CoreTests::test_object_identifier_4",
"tests/test_core.py::CoreTests::test_object_identifier_5",
"tests/test_core.py::CoreTests::test_object_identifier_6",
"tests/test_core.py::CoreTests::test_object_identifier_7",
"tests/test_core.py::CoreTests::test_object_identifier_8",
"tests/test_core.py::CoreTests::test_octet_bit_string",
"tests/test_core.py::CoreTests::test_octet_bit_string_errors_1",
"tests/test_core.py::CoreTests::test_octet_bit_string_errors_2",
"tests/test_core.py::CoreTests::test_octet_bit_string_errors_3",
"tests/test_core.py::CoreTests::test_oid_dotted_native",
"tests/test_core.py::CoreTests::test_oid_map_unmap",
"tests/test_core.py::CoreTests::test_parse_broken_sequence_fields_repeatedly",
"tests/test_core.py::CoreTests::test_parse_broken_sequenceof_children_repeatedly",
"tests/test_core.py::CoreTests::test_parse_universal_type_1",
"tests/test_core.py::CoreTests::test_replace_sequence_value",
"tests/test_core.py::CoreTests::test_required_field",
"tests/test_core.py::CoreTests::test_retag",
"tests/test_core.py::CoreTests::test_sequece_choice_choice",
"tests/test_core.py::CoreTests::test_sequence_any_asn1value",
"tests/test_core.py::CoreTests::test_sequence_any_native_value",
"tests/test_core.py::CoreTests::test_sequence_choice_field_by_dict",
"tests/test_core.py::CoreTests::test_sequence_choice_field_by_tuple",
"tests/test_core.py::CoreTests::test_sequence_of_spec",
"tests/test_core.py::CoreTests::test_sequence_spec",
"tests/test_core.py::CoreTests::test_strict",
"tests/test_core.py::CoreTests::test_strict_choice",
"tests/test_core.py::CoreTests::test_strict_concat",
"tests/test_core.py::CoreTests::test_strict_on_class",
"tests/test_core.py::CoreTests::test_truncated_1",
"tests/test_core.py::CoreTests::test_truncated_2",
"tests/test_core.py::CoreTests::test_truncated_3",
"tests/test_core.py::CoreTests::test_untag",
"tests/test_core.py::CoreTests::test_utctime_1",
"tests/test_core.py::CoreTests::test_utctime_2",
"tests/test_core.py::CoreTests::test_utctime_3",
"tests/test_core.py::CoreTests::test_utctime_4",
"tests/test_core.py::CoreTests::test_utctime_copy",
"tests/test_core.py::CoreTests::test_utctime_errors",
"tests/test_core.py::CoreTests::test_wrong_asn1value",
"tests/test_core.py::CoreTests::test_wrong_asn1value2",
"tests/test_core.py::CoreTests::test_wrong_asn1value3",
"tests/test_core.py::CoreTests::test_wrong_asn1value4"
]
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false
} | 2022-09-26 20:49:53+00:00 | mit | 6,229 |
|
wbond__asn1crypto-271 | diff --git a/asn1crypto/x509.py b/asn1crypto/x509.py
index a67ab1a..38aa770 100644
--- a/asn1crypto/x509.py
+++ b/asn1crypto/x509.py
@@ -27,7 +27,7 @@ import unicodedata
from ._errors import unwrap
from ._iri import iri_to_uri, uri_to_iri
from ._ordereddict import OrderedDict
-from ._types import type_name, str_cls, bytes_to_list
+from ._types import type_name, str_cls, byte_cls, bytes_to_list
from .algos import AlgorithmIdentifier, AnyAlgorithmIdentifier, DigestAlgorithm, SignedDigestAlgorithm
from .core import (
Any,
@@ -708,7 +708,13 @@ class NameTypeAndValue(Sequence):
"""
if self._prepped is None:
- self._prepped = self._ldap_string_prep(self['value'].native)
+ native = self['value'].native
+ if isinstance(native, str_cls):
+ self._prepped = self._ldap_string_prep(native)
+ else:
+ if isinstance(native, byte_cls):
+ native = ' ' + native.decode('cp1252') + ' '
+ self._prepped = native
return self._prepped
def __ne__(self, other):
| wbond/asn1crypto | 1a7a5bacfbea25dddf9d6f10dc11c8b7a327db10 | diff --git a/tests/test_x509.py b/tests/test_x509.py
index c177fe6..43e0bea 100644
--- a/tests/test_x509.py
+++ b/tests/test_x509.py
@@ -485,6 +485,23 @@ class X509Tests(unittest.TestCase):
self.assertEqual("unique_identifier", complex_name.chosen[3][0]['type'].native)
self.assertIsInstance(complex_name.chosen[3][0]['value'], core.OctetBitString)
+ def test_name_hashable(self):
+ complex_name = x509.Name.build(
+ {
+ 'country_name': 'US',
+ 'tpm_manufacturer': 'Acme Co',
+ 'unique_identifier': b'\x04\x10\x03\x09',
+ 'email_address': '[email protected]'
+ }
+ )
+ self.assertEqual(
+ "country_name: us \x1e"
+ "email_address: [email protected] \x1e"
+ "tpm_manufacturer: acme co \x1e"
+ "unique_identifier: \x04\x10\x03\x09 ",
+ complex_name.hashable
+ )
+
def test_v1_cert(self):
cert = self._load_cert('chromium/ndn.ca.crt')
tbs_cert = cert['tbs_certificate']
| NameTypeAndValue of type "unique_indentifier" cannot be prepared
Loosely related to issue #228 and PR #241.
Note that the `NameTypeAndValue` class can hold a `unique_identifier` which is an `OctetBitString`:
https://github.com/wbond/asn1crypto/blob/af8a325794b3c1c96860746dbde4ad46218645fe/asn1crypto/x509.py#L652
https://github.com/wbond/asn1crypto/blob/af8a325794b3c1c96860746dbde4ad46218645fe/asn1crypto/x509.py#L677
However, the `prepped_value` property relies on the value being a unicode string:
https://github.com/wbond/asn1crypto/blob/af8a325794b3c1c96860746dbde4ad46218645fe/asn1crypto/x509.py#L700-L712
For this reason, attempting to hash a `Name` with a `RDNSequence` that includes a `unique_identifier` fails with the following error:
```python
../../miniconda/envs/parsec/lib/python3.9/site-packages/asn1crypto/x509.py:1055: in hashable
return self.chosen.hashable
../../miniconda/envs/parsec/lib/python3.9/site-packages/asn1crypto/x509.py:949: in hashable
return '\x1E'.join(rdn.hashable for rdn in self)
../../miniconda/envs/parsec/lib/python3.9/site-packages/asn1crypto/x509.py:949: in <genexpr>
return '\x1E'.join(rdn.hashable for rdn in self)
../../miniconda/envs/parsec/lib/python3.9/site-packages/asn1crypto/x509.py:856: in hashable
values = self._get_values(self)
../../miniconda/envs/parsec/lib/python3.9/site-packages/asn1crypto/x509.py:925: in _get_values
for ntv in rdn:
../../miniconda/envs/parsec/lib/python3.9/site-packages/asn1crypto/x509.py:931: in <listcomp>
[output.update([(ntv['type'].native, ntv.prepped_value)]) for ntv in rdn]
../../miniconda/envs/parsec/lib/python3.9/site-packages/asn1crypto/x509.py:711: in prepped_value
self._prepped = self._ldap_string_prep(self['value'].native)
../../miniconda/envs/parsec/lib/python3.9/site-packages/asn1crypto/x509.py:749: in _ldap_string_prep
string = re.sub('[\u00ad\u1806\u034f\u180b-\u180d\ufe0f-\uff00\ufffc]+', '', string)
pattern = '[\xad᠆͏᠋-᠍️-\uff00]+', repl = '', string = b'test_ca', count = 0, flags = 0
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def sub(pattern, repl, string, count=0, flags=0):
"""Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl. repl can be either a string or a callable;
if a string, backslash escapes in it are processed. If it is
a callable, it's passed the Match object and must return
a replacement string to be used."""
> return _compile(pattern, flags).sub(repl, string, count)
E TypeError: cannot use a string pattern on a bytes-like object
../../miniconda/envs/parsec/lib/python3.9/re.py:210: TypeError
```
| 0.0 | 1a7a5bacfbea25dddf9d6f10dc11c8b7a327db10 | [
"tests/test_x509.py::X509Tests::test_name_hashable"
]
| [
"tests/test_x509.py::X509Tests::test_authority_information_access_value_1",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_10",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_11",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_12",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_13",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_14",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_15",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_16",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_2",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_3",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_4",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_5",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_6",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_7",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_8",
"tests/test_x509.py::X509Tests::test_authority_information_access_value_9",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_1",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_10",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_11",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_12",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_13",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_14",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_15",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_16",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_2",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_3",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_4",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_5",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_6",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_7",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_8",
"tests/test_x509.py::X509Tests::test_authority_issuer_serial_9",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_1",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_10",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_11",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_12",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_13",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_14",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_15",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_16",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_2",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_3",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_4",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_5",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_6",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_7",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_8",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_9",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_1",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_10",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_11",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_12",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_13",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_14",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_15",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_16",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_2",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_3",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_4",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_5",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_6",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_7",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_8",
"tests/test_x509.py::X509Tests::test_authority_key_identifier_value_9",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_1",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_10",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_11",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_12",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_13",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_14",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_15",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_16",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_2",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_3",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_4",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_5",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_6",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_7",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_8",
"tests/test_x509.py::X509Tests::test_basic_constraints_value_9",
"tests/test_x509.py::X509Tests::test_build_name_printable",
"tests/test_x509.py::X509Tests::test_build_name_type_by_oid",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_1",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_10",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_11",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_12",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_13",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_14",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_15",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_16",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_2",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_3",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_4",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_5",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_6",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_7",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_8",
"tests/test_x509.py::X509Tests::test_certificate_policies_value_9",
"tests/test_x509.py::X509Tests::test_cms_hash_algo_1",
"tests/test_x509.py::X509Tests::test_cms_hash_algo_2",
"tests/test_x509.py::X509Tests::test_cms_hash_algo_3",
"tests/test_x509.py::X509Tests::test_cms_hash_algo_4",
"tests/test_x509.py::X509Tests::test_cms_hash_algo_5",
"tests/test_x509.py::X509Tests::test_cms_hash_algo_6",
"tests/test_x509.py::X509Tests::test_cms_hash_algo_7",
"tests/test_x509.py::X509Tests::test_compare_dnsname_1",
"tests/test_x509.py::X509Tests::test_compare_dnsname_2",
"tests/test_x509.py::X509Tests::test_compare_dnsname_3",
"tests/test_x509.py::X509Tests::test_compare_dnsname_4",
"tests/test_x509.py::X509Tests::test_compare_dnsname_5",
"tests/test_x509.py::X509Tests::test_compare_email_address_1",
"tests/test_x509.py::X509Tests::test_compare_email_address_2",
"tests/test_x509.py::X509Tests::test_compare_email_address_3",
"tests/test_x509.py::X509Tests::test_compare_email_address_4",
"tests/test_x509.py::X509Tests::test_compare_email_address_5",
"tests/test_x509.py::X509Tests::test_compare_email_address_6",
"tests/test_x509.py::X509Tests::test_compare_email_address_7",
"tests/test_x509.py::X509Tests::test_compare_email_address_8",
"tests/test_x509.py::X509Tests::test_compare_ip_address_1",
"tests/test_x509.py::X509Tests::test_compare_ip_address_2",
"tests/test_x509.py::X509Tests::test_compare_ip_address_3",
"tests/test_x509.py::X509Tests::test_compare_ip_address_4",
"tests/test_x509.py::X509Tests::test_compare_ip_address_5",
"tests/test_x509.py::X509Tests::test_compare_name_1",
"tests/test_x509.py::X509Tests::test_compare_name_2",
"tests/test_x509.py::X509Tests::test_compare_name_3",
"tests/test_x509.py::X509Tests::test_compare_name_4",
"tests/test_x509.py::X509Tests::test_compare_name_5",
"tests/test_x509.py::X509Tests::test_compare_name_6",
"tests/test_x509.py::X509Tests::test_compare_name_7",
"tests/test_x509.py::X509Tests::test_compare_uri_1",
"tests/test_x509.py::X509Tests::test_compare_uri_2",
"tests/test_x509.py::X509Tests::test_compare_uri_3",
"tests/test_x509.py::X509Tests::test_compare_uri_4",
"tests/test_x509.py::X509Tests::test_compare_uri_5",
"tests/test_x509.py::X509Tests::test_compare_uri_6",
"tests/test_x509.py::X509Tests::test_compare_uri_7",
"tests/test_x509.py::X509Tests::test_critical_extensions_1",
"tests/test_x509.py::X509Tests::test_critical_extensions_10",
"tests/test_x509.py::X509Tests::test_critical_extensions_11",
"tests/test_x509.py::X509Tests::test_critical_extensions_12",
"tests/test_x509.py::X509Tests::test_critical_extensions_13",
"tests/test_x509.py::X509Tests::test_critical_extensions_14",
"tests/test_x509.py::X509Tests::test_critical_extensions_15",
"tests/test_x509.py::X509Tests::test_critical_extensions_16",
"tests/test_x509.py::X509Tests::test_critical_extensions_2",
"tests/test_x509.py::X509Tests::test_critical_extensions_3",
"tests/test_x509.py::X509Tests::test_critical_extensions_4",
"tests/test_x509.py::X509Tests::test_critical_extensions_5",
"tests/test_x509.py::X509Tests::test_critical_extensions_6",
"tests/test_x509.py::X509Tests::test_critical_extensions_7",
"tests/test_x509.py::X509Tests::test_critical_extensions_8",
"tests/test_x509.py::X509Tests::test_critical_extensions_9",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_1",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_10",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_11",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_12",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_13",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_14",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_15",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_16",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_2",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_3",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_4",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_5",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_6",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_7",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_8",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_9",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_1",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_10",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_11",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_12",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_13",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_14",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_15",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_16",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_2",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_3",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_4",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_5",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_6",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_7",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_8",
"tests/test_x509.py::X509Tests::test_crl_distribution_points_value_9",
"tests/test_x509.py::X509Tests::test_dnsname",
"tests/test_x509.py::X509Tests::test_dnsname_begin_dot",
"tests/test_x509.py::X509Tests::test_dump_generalname",
"tests/test_x509.py::X509Tests::test_email_address",
"tests/test_x509.py::X509Tests::test_extended_datetime",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_1",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_10",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_11",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_12",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_13",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_14",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_15",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_16",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_2",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_3",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_4",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_5",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_6",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_7",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_8",
"tests/test_x509.py::X509Tests::test_extended_key_usage_value_9",
"tests/test_x509.py::X509Tests::test_indef_dnsname",
"tests/test_x509.py::X509Tests::test_indef_email_address",
"tests/test_x509.py::X509Tests::test_indef_uri",
"tests/test_x509.py::X509Tests::test_invalid_email_encoding",
"tests/test_x509.py::X509Tests::test_ip_address_1",
"tests/test_x509.py::X509Tests::test_ip_address_2",
"tests/test_x509.py::X509Tests::test_ip_address_3",
"tests/test_x509.py::X509Tests::test_ip_address_4",
"tests/test_x509.py::X509Tests::test_ip_address_5",
"tests/test_x509.py::X509Tests::test_ip_address_6",
"tests/test_x509.py::X509Tests::test_ip_address_7",
"tests/test_x509.py::X509Tests::test_iri_with_port",
"tests/test_x509.py::X509Tests::test_is_valid_domain_ip_1",
"tests/test_x509.py::X509Tests::test_is_valid_domain_ip_2",
"tests/test_x509.py::X509Tests::test_is_valid_domain_ip_3",
"tests/test_x509.py::X509Tests::test_is_valid_domain_ip_4",
"tests/test_x509.py::X509Tests::test_is_valid_domain_ip_5",
"tests/test_x509.py::X509Tests::test_is_valid_domain_ip_6",
"tests/test_x509.py::X509Tests::test_issuer_serial_1",
"tests/test_x509.py::X509Tests::test_issuer_serial_10",
"tests/test_x509.py::X509Tests::test_issuer_serial_11",
"tests/test_x509.py::X509Tests::test_issuer_serial_12",
"tests/test_x509.py::X509Tests::test_issuer_serial_13",
"tests/test_x509.py::X509Tests::test_issuer_serial_14",
"tests/test_x509.py::X509Tests::test_issuer_serial_15",
"tests/test_x509.py::X509Tests::test_issuer_serial_16",
"tests/test_x509.py::X509Tests::test_issuer_serial_2",
"tests/test_x509.py::X509Tests::test_issuer_serial_3",
"tests/test_x509.py::X509Tests::test_issuer_serial_4",
"tests/test_x509.py::X509Tests::test_issuer_serial_5",
"tests/test_x509.py::X509Tests::test_issuer_serial_6",
"tests/test_x509.py::X509Tests::test_issuer_serial_7",
"tests/test_x509.py::X509Tests::test_issuer_serial_8",
"tests/test_x509.py::X509Tests::test_issuer_serial_9",
"tests/test_x509.py::X509Tests::test_key_identifier_1",
"tests/test_x509.py::X509Tests::test_key_identifier_10",
"tests/test_x509.py::X509Tests::test_key_identifier_11",
"tests/test_x509.py::X509Tests::test_key_identifier_12",
"tests/test_x509.py::X509Tests::test_key_identifier_13",
"tests/test_x509.py::X509Tests::test_key_identifier_14",
"tests/test_x509.py::X509Tests::test_key_identifier_15",
"tests/test_x509.py::X509Tests::test_key_identifier_16",
"tests/test_x509.py::X509Tests::test_key_identifier_2",
"tests/test_x509.py::X509Tests::test_key_identifier_3",
"tests/test_x509.py::X509Tests::test_key_identifier_4",
"tests/test_x509.py::X509Tests::test_key_identifier_5",
"tests/test_x509.py::X509Tests::test_key_identifier_6",
"tests/test_x509.py::X509Tests::test_key_identifier_7",
"tests/test_x509.py::X509Tests::test_key_identifier_8",
"tests/test_x509.py::X509Tests::test_key_identifier_9",
"tests/test_x509.py::X509Tests::test_key_identifier_value_1",
"tests/test_x509.py::X509Tests::test_key_identifier_value_10",
"tests/test_x509.py::X509Tests::test_key_identifier_value_11",
"tests/test_x509.py::X509Tests::test_key_identifier_value_12",
"tests/test_x509.py::X509Tests::test_key_identifier_value_13",
"tests/test_x509.py::X509Tests::test_key_identifier_value_14",
"tests/test_x509.py::X509Tests::test_key_identifier_value_15",
"tests/test_x509.py::X509Tests::test_key_identifier_value_16",
"tests/test_x509.py::X509Tests::test_key_identifier_value_2",
"tests/test_x509.py::X509Tests::test_key_identifier_value_3",
"tests/test_x509.py::X509Tests::test_key_identifier_value_4",
"tests/test_x509.py::X509Tests::test_key_identifier_value_5",
"tests/test_x509.py::X509Tests::test_key_identifier_value_6",
"tests/test_x509.py::X509Tests::test_key_identifier_value_7",
"tests/test_x509.py::X509Tests::test_key_identifier_value_8",
"tests/test_x509.py::X509Tests::test_key_identifier_value_9",
"tests/test_x509.py::X509Tests::test_key_usage_value_1",
"tests/test_x509.py::X509Tests::test_key_usage_value_10",
"tests/test_x509.py::X509Tests::test_key_usage_value_11",
"tests/test_x509.py::X509Tests::test_key_usage_value_12",
"tests/test_x509.py::X509Tests::test_key_usage_value_13",
"tests/test_x509.py::X509Tests::test_key_usage_value_14",
"tests/test_x509.py::X509Tests::test_key_usage_value_15",
"tests/test_x509.py::X509Tests::test_key_usage_value_16",
"tests/test_x509.py::X509Tests::test_key_usage_value_2",
"tests/test_x509.py::X509Tests::test_key_usage_value_3",
"tests/test_x509.py::X509Tests::test_key_usage_value_4",
"tests/test_x509.py::X509Tests::test_key_usage_value_5",
"tests/test_x509.py::X509Tests::test_key_usage_value_6",
"tests/test_x509.py::X509Tests::test_key_usage_value_7",
"tests/test_x509.py::X509Tests::test_key_usage_value_8",
"tests/test_x509.py::X509Tests::test_key_usage_value_9",
"tests/test_x509.py::X509Tests::test_name_constraints_value_1",
"tests/test_x509.py::X509Tests::test_name_constraints_value_10",
"tests/test_x509.py::X509Tests::test_name_constraints_value_11",
"tests/test_x509.py::X509Tests::test_name_constraints_value_12",
"tests/test_x509.py::X509Tests::test_name_constraints_value_13",
"tests/test_x509.py::X509Tests::test_name_constraints_value_14",
"tests/test_x509.py::X509Tests::test_name_constraints_value_15",
"tests/test_x509.py::X509Tests::test_name_constraints_value_16",
"tests/test_x509.py::X509Tests::test_name_constraints_value_2",
"tests/test_x509.py::X509Tests::test_name_constraints_value_3",
"tests/test_x509.py::X509Tests::test_name_constraints_value_4",
"tests/test_x509.py::X509Tests::test_name_constraints_value_5",
"tests/test_x509.py::X509Tests::test_name_constraints_value_6",
"tests/test_x509.py::X509Tests::test_name_constraints_value_7",
"tests/test_x509.py::X509Tests::test_name_constraints_value_8",
"tests/test_x509.py::X509Tests::test_name_constraints_value_9",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_1",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_10",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_11",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_12",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_13",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_14",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_15",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_2",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_3",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_4",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_5",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_6",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_7",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_8",
"tests/test_x509.py::X509Tests::test_name_is_rdn_squence_of_single_child_sets_9",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_1",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_10",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_11",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_12",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_13",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_14",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_15",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_16",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_2",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_3",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_4",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_5",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_6",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_7",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_8",
"tests/test_x509.py::X509Tests::test_ocsp_no_check_value_9",
"tests/test_x509.py::X509Tests::test_ocsp_urls_1",
"tests/test_x509.py::X509Tests::test_ocsp_urls_10",
"tests/test_x509.py::X509Tests::test_ocsp_urls_11",
"tests/test_x509.py::X509Tests::test_ocsp_urls_12",
"tests/test_x509.py::X509Tests::test_ocsp_urls_13",
"tests/test_x509.py::X509Tests::test_ocsp_urls_14",
"tests/test_x509.py::X509Tests::test_ocsp_urls_15",
"tests/test_x509.py::X509Tests::test_ocsp_urls_16",
"tests/test_x509.py::X509Tests::test_ocsp_urls_2",
"tests/test_x509.py::X509Tests::test_ocsp_urls_3",
"tests/test_x509.py::X509Tests::test_ocsp_urls_4",
"tests/test_x509.py::X509Tests::test_ocsp_urls_5",
"tests/test_x509.py::X509Tests::test_ocsp_urls_6",
"tests/test_x509.py::X509Tests::test_ocsp_urls_7",
"tests/test_x509.py::X509Tests::test_ocsp_urls_8",
"tests/test_x509.py::X509Tests::test_ocsp_urls_9",
"tests/test_x509.py::X509Tests::test_parse_certificate",
"tests/test_x509.py::X509Tests::test_parse_dsa_certificate",
"tests/test_x509.py::X509Tests::test_parse_dsa_certificate_inheritance",
"tests/test_x509.py::X509Tests::test_parse_ec_certificate",
"tests/test_x509.py::X509Tests::test_parse_ed25519_certificate",
"tests/test_x509.py::X509Tests::test_parse_ed448_certificate",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_1",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_10",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_11",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_12",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_13",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_14",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_15",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_16",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_2",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_3",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_4",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_5",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_6",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_7",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_8",
"tests/test_x509.py::X509Tests::test_policy_constraints_value_9",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_1",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_10",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_11",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_12",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_13",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_14",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_15",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_16",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_2",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_3",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_4",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_5",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_6",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_7",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_8",
"tests/test_x509.py::X509Tests::test_policy_mappings_value_9",
"tests/test_x509.py::X509Tests::test_private_key_usage_period_value_1",
"tests/test_x509.py::X509Tests::test_punycode_common_name",
"tests/test_x509.py::X509Tests::test_repeated_subject_fields",
"tests/test_x509.py::X509Tests::test_self_issued_1",
"tests/test_x509.py::X509Tests::test_self_issued_10",
"tests/test_x509.py::X509Tests::test_self_issued_11",
"tests/test_x509.py::X509Tests::test_self_issued_12",
"tests/test_x509.py::X509Tests::test_self_issued_13",
"tests/test_x509.py::X509Tests::test_self_issued_14",
"tests/test_x509.py::X509Tests::test_self_issued_15",
"tests/test_x509.py::X509Tests::test_self_issued_16",
"tests/test_x509.py::X509Tests::test_self_issued_2",
"tests/test_x509.py::X509Tests::test_self_issued_3",
"tests/test_x509.py::X509Tests::test_self_issued_4",
"tests/test_x509.py::X509Tests::test_self_issued_5",
"tests/test_x509.py::X509Tests::test_self_issued_6",
"tests/test_x509.py::X509Tests::test_self_issued_7",
"tests/test_x509.py::X509Tests::test_self_issued_8",
"tests/test_x509.py::X509Tests::test_self_issued_9",
"tests/test_x509.py::X509Tests::test_self_signed_1",
"tests/test_x509.py::X509Tests::test_self_signed_10",
"tests/test_x509.py::X509Tests::test_self_signed_11",
"tests/test_x509.py::X509Tests::test_self_signed_12",
"tests/test_x509.py::X509Tests::test_self_signed_13",
"tests/test_x509.py::X509Tests::test_self_signed_14",
"tests/test_x509.py::X509Tests::test_self_signed_15",
"tests/test_x509.py::X509Tests::test_self_signed_16",
"tests/test_x509.py::X509Tests::test_self_signed_2",
"tests/test_x509.py::X509Tests::test_self_signed_3",
"tests/test_x509.py::X509Tests::test_self_signed_4",
"tests/test_x509.py::X509Tests::test_self_signed_5",
"tests/test_x509.py::X509Tests::test_self_signed_6",
"tests/test_x509.py::X509Tests::test_self_signed_7",
"tests/test_x509.py::X509Tests::test_self_signed_8",
"tests/test_x509.py::X509Tests::test_self_signed_9",
"tests/test_x509.py::X509Tests::test_serial_number_1",
"tests/test_x509.py::X509Tests::test_serial_number_10",
"tests/test_x509.py::X509Tests::test_serial_number_11",
"tests/test_x509.py::X509Tests::test_serial_number_12",
"tests/test_x509.py::X509Tests::test_serial_number_13",
"tests/test_x509.py::X509Tests::test_serial_number_14",
"tests/test_x509.py::X509Tests::test_serial_number_15",
"tests/test_x509.py::X509Tests::test_serial_number_16",
"tests/test_x509.py::X509Tests::test_serial_number_2",
"tests/test_x509.py::X509Tests::test_serial_number_3",
"tests/test_x509.py::X509Tests::test_serial_number_4",
"tests/test_x509.py::X509Tests::test_serial_number_5",
"tests/test_x509.py::X509Tests::test_serial_number_6",
"tests/test_x509.py::X509Tests::test_serial_number_7",
"tests/test_x509.py::X509Tests::test_serial_number_8",
"tests/test_x509.py::X509Tests::test_serial_number_9",
"tests/test_x509.py::X509Tests::test_sha1_fingerprint",
"tests/test_x509.py::X509Tests::test_sha256_fingerprint",
"tests/test_x509.py::X509Tests::test_signature_algo_1",
"tests/test_x509.py::X509Tests::test_signature_algo_2",
"tests/test_x509.py::X509Tests::test_signature_algo_3",
"tests/test_x509.py::X509Tests::test_signature_algo_4",
"tests/test_x509.py::X509Tests::test_signature_algo_5",
"tests/test_x509.py::X509Tests::test_signature_algo_6",
"tests/test_x509.py::X509Tests::test_signature_algo_7",
"tests/test_x509.py::X509Tests::test_strict_teletex",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_1",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_10",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_11",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_12",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_13",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_14",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_15",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_16",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_2",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_3",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_4",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_5",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_6",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_7",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_8",
"tests/test_x509.py::X509Tests::test_subject_alt_name_value_9",
"tests/test_x509.py::X509Tests::test_subject_alt_name_variations",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_1",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_10",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_11",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_12",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_13",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_14",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_15",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_16",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_2",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_3",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_4",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_5",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_6",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_7",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_8",
"tests/test_x509.py::X509Tests::test_subject_directory_attributes_value_9",
"tests/test_x509.py::X509Tests::test_teletex_that_is_really_latin1",
"tests/test_x509.py::X509Tests::test_trusted_certificate",
"tests/test_x509.py::X509Tests::test_uri",
"tests/test_x509.py::X509Tests::test_uri_no_normalization",
"tests/test_x509.py::X509Tests::test_v1_cert",
"tests/test_x509.py::X509Tests::test_valid_domains_1",
"tests/test_x509.py::X509Tests::test_valid_domains_10",
"tests/test_x509.py::X509Tests::test_valid_domains_11",
"tests/test_x509.py::X509Tests::test_valid_domains_12",
"tests/test_x509.py::X509Tests::test_valid_domains_13",
"tests/test_x509.py::X509Tests::test_valid_domains_14",
"tests/test_x509.py::X509Tests::test_valid_domains_15",
"tests/test_x509.py::X509Tests::test_valid_domains_16",
"tests/test_x509.py::X509Tests::test_valid_domains_2",
"tests/test_x509.py::X509Tests::test_valid_domains_3",
"tests/test_x509.py::X509Tests::test_valid_domains_4",
"tests/test_x509.py::X509Tests::test_valid_domains_5",
"tests/test_x509.py::X509Tests::test_valid_domains_6",
"tests/test_x509.py::X509Tests::test_valid_domains_7",
"tests/test_x509.py::X509Tests::test_valid_domains_8",
"tests/test_x509.py::X509Tests::test_valid_domains_9",
"tests/test_x509.py::X509Tests::test_valid_ips_1",
"tests/test_x509.py::X509Tests::test_valid_ips_10",
"tests/test_x509.py::X509Tests::test_valid_ips_11",
"tests/test_x509.py::X509Tests::test_valid_ips_12",
"tests/test_x509.py::X509Tests::test_valid_ips_13",
"tests/test_x509.py::X509Tests::test_valid_ips_14",
"tests/test_x509.py::X509Tests::test_valid_ips_15",
"tests/test_x509.py::X509Tests::test_valid_ips_16",
"tests/test_x509.py::X509Tests::test_valid_ips_2",
"tests/test_x509.py::X509Tests::test_valid_ips_3",
"tests/test_x509.py::X509Tests::test_valid_ips_4",
"tests/test_x509.py::X509Tests::test_valid_ips_5",
"tests/test_x509.py::X509Tests::test_valid_ips_6",
"tests/test_x509.py::X509Tests::test_valid_ips_7",
"tests/test_x509.py::X509Tests::test_valid_ips_8",
"tests/test_x509.py::X509Tests::test_valid_ips_9",
"tests/test_x509.py::X509Tests::test_validity_after_before"
]
| {
"failed_lite_validators": [
"has_issue_reference"
],
"has_test_patch": true,
"is_lite": false
} | 2023-11-03 11:44:20+00:00 | mit | 6,230 |
|
wearewhys__magnivore-12 | diff --git a/magnivore/Lexicon.py b/magnivore/Lexicon.py
index f9fa08d..84ae7a2 100644
--- a/magnivore/Lexicon.py
+++ b/magnivore/Lexicon.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import re
+from decimal import Decimal
from functools import reduce
from .Tracker import Tracker
@@ -38,7 +39,8 @@ class Lexicon:
The factor rule multiplies the value by a factor.
"""
value = cls._dot_reduce(rule['from'], target)
- return value * rule['factor']
+ original_type = type(value)
+ return original_type(Decimal(value) * Decimal(rule['factor']))
@classmethod
def format(cls, rule, target):
| wearewhys/magnivore | be723f7f575376d0ce25b0590bd46dcc6f34ace8 | diff --git a/tests/unit/Lexicon.py b/tests/unit/Lexicon.py
index 4f8e888..f1c85d6 100644
--- a/tests/unit/Lexicon.py
+++ b/tests/unit/Lexicon.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import re
+from decimal import Decimal
from unittest.mock import MagicMock
from magnivore.Lexicon import Lexicon
@@ -48,17 +49,20 @@ def test_lexicon_transform(target):
assert result == rule['transform'][target.temperature]
[email protected]('from_data, target', [
- ('value', MagicMock(value=100)),
- ('related.value', MagicMock(related=MagicMock(value=100)))
[email protected]('from_data, target, expected', [
+ ('value', MagicMock(value=100), 50),
+ ('value', MagicMock(value=Decimal(100)), Decimal(50)),
+ ('value', MagicMock(value=100.0), 50.0),
+ ('related.value', MagicMock(related=MagicMock(value=100)), 50)
])
-def test_lexicon_factor(from_data, target):
+def test_lexicon_factor(from_data, target, expected):
rule = {
'from': from_data,
'factor': 0.5
}
result = Lexicon.factor(rule, target)
- assert result == 50
+ assert result == expected
+ assert type(result) == type(expected)
@mark.parametrize('from_data, format, expected', [
| Lexicon.factor should check the type of the values
Lexicon.factor should check the values types or errors will happen | 0.0 | be723f7f575376d0ce25b0590bd46dcc6f34ace8 | [
"tests/unit/Lexicon.py::test_lexicon_factor[value-target0-50]",
"tests/unit/Lexicon.py::test_lexicon_factor[value-target1-expected1]",
"tests/unit/Lexicon.py::test_lexicon_factor[related.value-target3-50]"
]
| [
"tests/unit/Lexicon.py::test_lexicon_basic",
"tests/unit/Lexicon.py::test_lexicon_basic_dot",
"tests/unit/Lexicon.py::test_lexicon_basic_dot_double",
"tests/unit/Lexicon.py::test_lexicon_basic_null[field]",
"tests/unit/Lexicon.py::test_lexicon_basic_null[table.field]",
"tests/unit/Lexicon.py::test_lexicon_basic_null[table.field.nested]",
"tests/unit/Lexicon.py::test_lexicon_transform[target0]",
"tests/unit/Lexicon.py::test_lexicon_transform[target1]",
"tests/unit/Lexicon.py::test_lexicon_factor[value-target2-50.0]",
"tests/unit/Lexicon.py::test_lexicon_format[birthyear-{}-0-0-1992-0-0]",
"tests/unit/Lexicon.py::test_lexicon_format[from_data1-{}-{}-0-1992-9-0]",
"tests/unit/Lexicon.py::test_lexicon_format_dot[rel.birthyear-{}-0-0-1992-0-0]",
"tests/unit/Lexicon.py::test_lexicon_format_dot[from_data1-{}-{}-0-1992-9-0]",
"tests/unit/Lexicon.py::test_lexicon_match",
"tests/unit/Lexicon.py::test_lexicon_match_none",
"tests/unit/Lexicon.py::test_lexicon_match_from",
"tests/unit/Lexicon.py::test_lexicon_match_dot",
"tests/unit/Lexicon.py::test_lexicon_match_from_none",
"tests/unit/Lexicon.py::test_lexicon_match_none_log",
"tests/unit/Lexicon.py::test_lexicon_sync",
"tests/unit/Lexicon.py::test_lexicon_sync_none",
"tests/unit/Lexicon.py::test_lexicon_static",
"tests/unit/Lexicon.py::test_lexicon_expression",
"tests/unit/Lexicon.py::test_lexicon_expression_dot",
"tests/unit/Lexicon.py::test_lexicon_expression_none"
]
| {
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false
} | 2017-11-21 11:53:18+00:00 | apache-2.0 | 6,231 |
|
wearewhys__magnivore-14 | diff --git a/magnivore/Lexicon.py b/magnivore/Lexicon.py
index 84ae7a2..acf038b 100644
--- a/magnivore/Lexicon.py
+++ b/magnivore/Lexicon.py
@@ -2,6 +2,7 @@
import re
from decimal import Decimal
from functools import reduce
+from math import ceil, floor
from .Tracker import Tracker
@@ -40,7 +41,12 @@ class Lexicon:
"""
value = cls._dot_reduce(rule['from'], target)
original_type = type(value)
- return original_type(Decimal(value) * Decimal(rule['factor']))
+ result = Decimal(value) * Decimal(rule['factor'])
+ if 'round' in rule:
+ if rule['round'] == 'up':
+ return original_type(ceil(result))
+ return original_type(floor(result))
+ return original_type(result)
@classmethod
def format(cls, rule, target):
| wearewhys/magnivore | acf182faeb0cf80157ec5d7b448b355687dcbd94 | diff --git a/tests/unit/Lexicon.py b/tests/unit/Lexicon.py
index f1c85d6..3af833c 100644
--- a/tests/unit/Lexicon.py
+++ b/tests/unit/Lexicon.py
@@ -65,6 +65,19 @@ def test_lexicon_factor(from_data, target, expected):
assert type(result) == type(expected)
[email protected]('rounding, expected', [
+ ('down', 47),
+ ('up', 48)
+])
+def test_lexicon_factor_round(rounding, expected):
+ rule = {
+ 'from': 'value',
+ 'round': rounding,
+ 'factor': 0.5
+ }
+ assert Lexicon.factor(rule, MagicMock(value=95)) == expected
+
+
@mark.parametrize('from_data, format, expected', [
('birthyear', '{}-0-0', '1992-0-0'),
(['birthyear', 'birthmonth'], '{}-{}-0', '1992-9-0')
| Add possibility to specify whether to round up or down in factor | 0.0 | acf182faeb0cf80157ec5d7b448b355687dcbd94 | [
"tests/unit/Lexicon.py::test_lexicon_factor_round[up-48]"
]
| [
"tests/unit/Lexicon.py::test_lexicon_basic",
"tests/unit/Lexicon.py::test_lexicon_basic_dot",
"tests/unit/Lexicon.py::test_lexicon_basic_dot_double",
"tests/unit/Lexicon.py::test_lexicon_basic_null[field]",
"tests/unit/Lexicon.py::test_lexicon_basic_null[table.field]",
"tests/unit/Lexicon.py::test_lexicon_basic_null[table.field.nested]",
"tests/unit/Lexicon.py::test_lexicon_transform[target0]",
"tests/unit/Lexicon.py::test_lexicon_transform[target1]",
"tests/unit/Lexicon.py::test_lexicon_factor[value-target0-50]",
"tests/unit/Lexicon.py::test_lexicon_factor[value-target1-expected1]",
"tests/unit/Lexicon.py::test_lexicon_factor[value-target2-50.0]",
"tests/unit/Lexicon.py::test_lexicon_factor[related.value-target3-50]",
"tests/unit/Lexicon.py::test_lexicon_factor_round[down-47]",
"tests/unit/Lexicon.py::test_lexicon_format[birthyear-{}-0-0-1992-0-0]",
"tests/unit/Lexicon.py::test_lexicon_format[from_data1-{}-{}-0-1992-9-0]",
"tests/unit/Lexicon.py::test_lexicon_format_dot[rel.birthyear-{}-0-0-1992-0-0]",
"tests/unit/Lexicon.py::test_lexicon_format_dot[from_data1-{}-{}-0-1992-9-0]",
"tests/unit/Lexicon.py::test_lexicon_match",
"tests/unit/Lexicon.py::test_lexicon_match_none",
"tests/unit/Lexicon.py::test_lexicon_match_from",
"tests/unit/Lexicon.py::test_lexicon_match_dot",
"tests/unit/Lexicon.py::test_lexicon_match_from_none",
"tests/unit/Lexicon.py::test_lexicon_match_none_log",
"tests/unit/Lexicon.py::test_lexicon_sync",
"tests/unit/Lexicon.py::test_lexicon_sync_none",
"tests/unit/Lexicon.py::test_lexicon_static",
"tests/unit/Lexicon.py::test_lexicon_expression",
"tests/unit/Lexicon.py::test_lexicon_expression_dot",
"tests/unit/Lexicon.py::test_lexicon_expression_none"
]
| {
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false
} | 2017-11-21 15:44:33+00:00 | apache-2.0 | 6,232 |
|
wearewhys__magnivore-9 | diff --git a/magnivore/Targets.py b/magnivore/Targets.py
index c2aa61c..27ce660 100644
--- a/magnivore/Targets.py
+++ b/magnivore/Targets.py
@@ -66,6 +66,16 @@ class Targets:
return query.join(model, 'LEFT OUTER', on=expression)
return query.join(model, on=expression)
+ def _apply_pick(self, query, join):
+ model = self.source_models[join['table']]
+ selects = []
+ for column, value in join['picks'].items():
+ if value is True:
+ selects.append(getattr(model, column))
+ elif value == 'sum':
+ selects.append(fn.Sum(getattr(model, column)))
+ return query.select(*selects)
+
def get(self, joins, limit=None, offset=0):
"""
Retrieves the targets for the given joins
@@ -76,6 +86,7 @@ class Targets:
aggregations = []
conditions = []
models = []
+ picks = []
for join in joins:
models.append(self.source_models[join['table']])
if 'conditions' in join:
@@ -84,7 +95,14 @@ class Targets:
if 'aggregation' in join:
aggregations.append(join)
- query = models[0].select(*models)
+ if 'picks' in join:
+ picks.append(join)
+
+ query = models[0]
+ if picks == []:
+ query = query.select(*models)
+ for pick in picks:
+ query = self._apply_pick(query, pick)
joins.pop(0)
for join in joins:
| wearewhys/magnivore | a9c896df3d054cb943a7f07540e04697952e0d62 | diff --git a/tests/unit/Targets.py b/tests/unit/Targets.py
index a0668e5..159af9c 100644
--- a/tests/unit/Targets.py
+++ b/tests/unit/Targets.py
@@ -193,6 +193,24 @@ def test_get_aggregations_eq(mocker, targets, joins, nodes, nodes_query):
assert nodes_query.join().group_by().having().execute.call_count == 1
+def test_get_picks(targets, joins, nodes, nodes_query):
+ joins[0]['picks'] = {
+ 'field': True
+ }
+ targets.get(joins)
+ nodes.select.assert_called_with(nodes.field)
+ assert nodes_query.join().execute.call_count == 1
+
+
+def test_get_picks_sum(targets, joins, nodes, nodes_query):
+ joins[0]['picks'] = {
+ 'field': 'sum'
+ }
+ targets.get(joins)
+ nodes.select.assert_called_with(fn.Sum(nodes.field))
+ assert nodes_query.join().execute.call_count == 1
+
+
def test_get_log_query(targets, joins, nodes_query, logger):
targets.get(joins)
calls = [call.logger.log('get-targets', nodes_query.join())]
| Add ability to specify selected columns
It should be possible to specify the columns to be selected in when retrieving items. This is necessary as it would allow to retrieve aggregated sets e.g. count queries | 0.0 | a9c896df3d054cb943a7f07540e04697952e0d62 | [
"tests/unit/Targets.py::test_get_picks",
"tests/unit/Targets.py::test_get_picks_sum"
]
| [
"tests/unit/Targets.py::test_get_targets_empty",
"tests/unit/Targets.py::test_get",
"tests/unit/Targets.py::test_get_triple_join",
"tests/unit/Targets.py::test_get_limit",
"tests/unit/Targets.py::test_get_limit_with_offset",
"tests/unit/Targets.py::test_get_switch",
"tests/unit/Targets.py::test_get_join_on",
"tests/unit/Targets.py::test_get_join_outer",
"tests/unit/Targets.py::test_get_conditions",
"tests/unit/Targets.py::test_get_conditions_greater[gt]",
"tests/unit/Targets.py::test_get_conditions_greater[lt]",
"tests/unit/Targets.py::test_get_conditions_greater[not]",
"tests/unit/Targets.py::test_get_conditions_in",
"tests/unit/Targets.py::test_get_conditions_isnull",
"tests/unit/Targets.py::test_get_aggregations",
"tests/unit/Targets.py::test_get_aggregations_eq",
"tests/unit/Targets.py::test_get_log_query",
"tests/unit/Targets.py::test_get_log_targets_count"
]
| {
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false
} | 2017-11-20 15:44:17+00:00 | apache-2.0 | 6,233 |
|
weaveworks__grafanalib-301 | diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 808dfe3..20f0ccc 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -6,7 +6,7 @@ Changelog
===========
* Added Logs panel (https://grafana.com/docs/grafana/latest/panels/visualizations/logs-panel/)
-* ...
+* Added Cloudwatch metrics datasource (https://grafana.com/docs/grafana/latest/datasources/cloudwatch/)
Changes
-------
diff --git a/docs/api/grafanalib.rst b/docs/api/grafanalib.rst
index 4638337..7ac152a 100644
--- a/docs/api/grafanalib.rst
+++ b/docs/api/grafanalib.rst
@@ -4,6 +4,14 @@ grafanalib package
Submodules
----------
+grafanalib.cloudwatch module
+----------------------------
+
+.. automodule:: grafanalib.cloudwatch
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
grafanalib.core module
----------------------
@@ -20,6 +28,22 @@ grafanalib.elasticsearch module
:undoc-members:
:show-inheritance:
+grafanalib.formatunits module
+-----------------------------
+
+.. automodule:: grafanalib.formatunits
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
+grafanalib.influxdb module
+--------------------------
+
+.. automodule:: grafanalib.influxdb
+ :members:
+ :undoc-members:
+ :show-inheritance:
+
grafanalib.opentsdb module
--------------------------
@@ -60,7 +84,6 @@ grafanalib.zabbix module
:undoc-members:
:show-inheritance:
-
Module contents
---------------
diff --git a/grafanalib/cloudwatch.py b/grafanalib/cloudwatch.py
new file mode 100644
index 0000000..15f059d
--- /dev/null
+++ b/grafanalib/cloudwatch.py
@@ -0,0 +1,57 @@
+"""Helpers to create Cloudwatch-specific Grafana queries."""
+
+import attr
+
+from attr.validators import instance_of
+
+
[email protected]
+class CloudwatchMetricsTarget(object):
+ """
+ Generates Cloudwatch target JSON structure.
+
+ Grafana docs on using Cloudwatch:
+ https://grafana.com/docs/grafana/latest/datasources/cloudwatch/
+
+ AWS docs on Cloudwatch metrics:
+ https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html
+
+ :param alias: legend alias
+ :param dimensions: Cloudwatch dimensions dict
+ :param expression: Cloudwatch Metric math expressions
+ :param id: unique id
+ :param matchExact: Only show metrics that exactly match all defined dimension names.
+ :param metricName: Cloudwatch metric name
+ :param namespace: Cloudwatch namespace
+ :param period: Cloudwatch data period
+ :param refId: target reference id
+ :param region: Cloudwatch region
+ :param statistics: Cloudwatch mathematic statistic
+ """
+ alias = attr.ib(default="")
+ dimensions = attr.ib(default={}, validator=instance_of(dict))
+ expression = attr.ib(default="")
+ id = attr.ib(default="")
+ matchExact = attr.ib(default=True, validator=instance_of(bool))
+ metricName = attr.ib(default="")
+ namespace = attr.ib(default="")
+ period = attr.ib(default="")
+ refId = attr.ib(default="")
+ region = attr.ib(default="default")
+ statistics = attr.ib(default=["Average"], validator=instance_of(list))
+
+ def to_json_data(self):
+
+ return {
+ "alias": self.alias,
+ "dimensions": self.dimensions,
+ "expression": self.expression,
+ "id": self.id,
+ "matchExact": self.matchExact,
+ "metricName": self.metricName,
+ "namespace": self.namespace,
+ "period": self.period,
+ "refId": self.refId,
+ "region": self.region,
+ "statistics": self.statistics
+ }
| weaveworks/grafanalib | e010c779d85f5ff28896ca94f549f92e4170b13e | diff --git a/grafanalib/tests/test_cloudwatch.py b/grafanalib/tests/test_cloudwatch.py
new file mode 100644
index 0000000..b9e91bb
--- /dev/null
+++ b/grafanalib/tests/test_cloudwatch.py
@@ -0,0 +1,25 @@
+"""Tests for Cloudwatch Datasource"""
+
+import grafanalib.core as G
+import grafanalib.cloudwatch as C
+from grafanalib import _gen
+from io import StringIO
+
+
+def test_serialization_cloudwatch_metrics_target():
+ """Serializing a graph doesn't explode."""
+ graph = G.Graph(
+ title="Lambda Duration",
+ dataSource="Cloudwatch data source",
+ targets=[
+ C.CloudwatchMetricsTarget(),
+ ],
+ id=1,
+ yAxes=G.YAxes(
+ G.YAxis(format=G.SHORT_FORMAT, label="ms"),
+ G.YAxis(format=G.SHORT_FORMAT),
+ ),
+ )
+ stream = StringIO()
+ _gen.write_dashboard(graph, stream)
+ assert stream.getvalue() != ''
| Cloudwatch datasources not supported due to Target class restrictions
There is no support for Cloudwatch since the Target class has restrictions. If you remove them, you'll be able to make Cloudwatch graphs. | 0.0 | e010c779d85f5ff28896ca94f549f92e4170b13e | [
"grafanalib/tests/test_cloudwatch.py::test_serialization_cloudwatch_metrics_target"
]
| []
| {
"failed_lite_validators": [
"has_short_problem_statement",
"has_added_files",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false
} | 2021-01-05 16:19:33+00:00 | apache-2.0 | 6,234 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.