Skip to content

Commit

Permalink
test: skip if varname is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
eddieantonio committed Dec 31, 2020
1 parent c44848e commit 3cfc412
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: Test and Lint

on:
push:
Expand All @@ -16,6 +16,7 @@ jobs:
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
extras: [null, 'varname']

steps:
- uses: actions/checkout@v2
Expand All @@ -27,6 +28,10 @@ jobs:
run: |
python -m pip install poetry
poetry install
- name: Install extras
if: ${{ matrix.extras }}
run: |
poetry install --extras ${{ matrix.extras }}
- name: Format with Black
run: |
poetry run black --check --diff sentinel.py
Expand Down
12 changes: 10 additions & 2 deletions test_sentinel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

import sentinel

try:
import varname # type: ignore
except ImportError:
HAS_VARNAME = False
else:
HAS_VARNAME = True

# Must be defined at module-level due to limitations in how the pickle module works :/
Pickleable = sentinel.create("Pickleable")

Expand Down Expand Up @@ -144,9 +151,10 @@ def test_copy():
assert copied[Copyable][1] is not arbitrary_data_structure[Copyable][1]


def test_varnames():
@pytest.mark.skipif(not HAS_VARNAME, reason="varname PyPI package not installed")
def test_varname():
"""
Test support with Python varnames,
Tests infering the variable name. Requires varname library be installed.
"""

Dark = sentinel.create()
Expand Down

0 comments on commit 3cfc412

Please sign in to comment.