Skip to content

Commit 3cfc412

Browse files
committed
test: skip if varname is not installed
1 parent c44848e commit 3cfc412

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

.github/workflows/python-package.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python package
4+
name: Test and Lint
55

66
on:
77
push:
@@ -16,6 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
python-version: ['3.6', '3.7', '3.8', '3.9']
19+
extras: [null, 'varname']
1920

2021
steps:
2122
- uses: actions/checkout@v2
@@ -27,6 +28,10 @@ jobs:
2728
run: |
2829
python -m pip install poetry
2930
poetry install
31+
- name: Install extras
32+
if: ${{ matrix.extras }}
33+
run: |
34+
poetry install --extras ${{ matrix.extras }}
3035
- name: Format with Black
3136
run: |
3237
poetry run black --check --diff sentinel.py

test_sentinel.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
import sentinel
1010

11+
try:
12+
import varname # type: ignore
13+
except ImportError:
14+
HAS_VARNAME = False
15+
else:
16+
HAS_VARNAME = True
17+
1118
# Must be defined at module-level due to limitations in how the pickle module works :/
1219
Pickleable = sentinel.create("Pickleable")
1320

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

146153

147-
def test_varnames():
154+
@pytest.mark.skipif(not HAS_VARNAME, reason="varname PyPI package not installed")
155+
def test_varname():
148156
"""
149-
Test support with Python varnames,
157+
Tests infering the variable name. Requires varname library be installed.
150158
"""
151159

152160
Dark = sentinel.create()

0 commit comments

Comments
 (0)