-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathnoxfile.py
More file actions
76 lines (58 loc) · 2.35 KB
/
Copy pathnoxfile.py
File metadata and controls
76 lines (58 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# this file is *not* meant to cover or endorse the use of nox or pytest or
# testing in general,
#
# It's meant to show the use of:
#
# - check-manifest
# confirm items checked into vcs are in your sdist
# - readme_renderer (when using a reStructuredText README)
# confirms your long_description will render correctly on PyPI.
#
# and also to help confirm pull requests to this project.
import nox
import os
nox.options.sessions = ["lint"]
# Define the minimal nox version required to run
nox.needs_version = ">= 2024.3.2"
@nox.session
def lint(session):
session.install("flake8")
session.run(
"flake8", "--exclude", ".nox,*.egg,build,data",
"--select", "E,W,F", "."
)
@nox.session
def build_and_check_dists(session):
session.install("build", "check-manifest >= 0.42", "twine")
session.run("check-manifest", "--ignore", "jsonata/**,noxfile.py,tests/**")
session.run("python", "-m", "build")
session.run("python", "-m", "twine", "check", "dist/*")
@nox.session(python=["3.10", "3.11", "3.12", "3.13", "3.14"])
def tests(session):
session.install("pytest")
session.install("pytest-asyncio")
build_and_check_dists(session)
generated_files = os.listdir("dist/")
sdists = [f for f in generated_files if f.endswith(".tar.gz")]
if not sdists:
session.error("No sdist (.tar.gz) found in dist/")
generated_sdist = max((os.path.join("dist/", f) for f in sdists), key=os.path.getmtime)
session.install(generated_sdist)
session.run("python", "tests/generate.py")
session.run("py.test", "tests/", *session.posargs)
# Exercises the optional pluggable regex_engine hook against Google's RE2
# (tests/re2_engine_test.py). Kept as its own session so the main `tests`
# session -- and the package itself -- stay free of a google-re2 dependency;
# this one opts in explicitly.
@nox.session
def test_re2(session):
session.install("pytest")
session.install("google-re2")
build_and_check_dists(session)
generated_files = os.listdir("dist/")
sdists = [f for f in generated_files if f.endswith(".tar.gz")]
if not sdists:
session.error("No sdist (.tar.gz) found in dist/")
generated_sdist = max((os.path.join("dist/", f) for f in sdists), key=os.path.getmtime)
session.install(generated_sdist)
session.run("py.test", "tests/re2_engine_test.py", *session.posargs)