Skip to content

Commit

Permalink
Merge branch 'master' into master.tracing-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raddessi committed Mar 4, 2021
2 parents 85b750b + 1d464b0 commit d718aca
Show file tree
Hide file tree
Showing 7 changed files with 816 additions and 4 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/py3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ jobs:
with:
python-version: ${{ matrix.python }}

- name: Install pynetbox and testing packages.
run: pip install . black==19.10b0 pytest
- name: Install dev requirements
run: pip install -r requirements-dev.txt .

- name: Run Linter
run: black --diff --check pynetbox tests

- name: Run Tests
run: pytest

6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,8 @@ ENV/
/site

# mypy
.mypy_cache/
.mypy_cache/

# Other git repos checked out locally
.netbox-docker-*/
.devicetype-library/
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
black==19.10b0
Faker==6.5.*
pytest==6.2.*
pytest-docker==0.10.*
43 changes: 43 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from packaging import version


DEFAULT_NETBOX_VERSIONS = "2.7, 2.8, 2.9, 2.10"


def pytest_addoption(parser):
"""Hook on the pytest option parser setup.
Add some extra options to the parser.
"""
parser.addoption(
"--netbox-versions",
action="store",
default=DEFAULT_NETBOX_VERSIONS,
help=(
"The versions of netbox to run integration tests against, as a"
" comma-separated list. Default: %s" % DEFAULT_NETBOX_VERSIONS
),
)

parser.addoption(
"--no-cleanup",
dest="cleanup",
action="store_false",
help=(
"Skip any cleanup steps after the pytest session finishes. Any containers"
" created will be left running and the docker-compose files used to"
" create them will be left on disk."
),
)


def pytest_configure(config):
"""Hook that runs after test collection is completed.
Here we can modify items in the collected tests or parser args.
"""
# verify the netbox versions parse correctly and split them
config.option.netbox_versions = [
version.Version(version_string)
for version_string in config.option.netbox_versions.split(",")
]
Loading

0 comments on commit d718aca

Please sign in to comment.