Skip to content

Commit 6ef8a91

Browse files
committed
test pyproject extra
1 parent 19401ab commit 6ef8a91

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ s3 = ["boto3"]
5454
gcs = ["google-api-python-client"]
5555

5656
[tool.pytest.ini_options]
57-
addopts = "--strict-markers"
57+
addopts = "--strict-markers -m 'not no_gcs and not no_s3'"
5858
testpaths = "test"
5959
markers = [
6060
"gcs",
6161
"s3",
62+
"no_gcs",
63+
"no_s3"
6264
]
6365

6466
[tool.flake8]

test/test_pyproject_extra.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import unittest
2+
3+
import pytest
4+
5+
6+
class TestPyprojectExtra(unittest.TestCase):
7+
8+
@pytest.mark.gcs
9+
def test_gcs_installed(self):
10+
try:
11+
import googleapiclient # noqa: F401
12+
except ImportError:
13+
raise Exception('googleapiclient should be installed')
14+
15+
@pytest.mark.no_gcs
16+
def test_no_gcs(self):
17+
try:
18+
import googleapiclient # noqa: F401
19+
raise Exception('googleapiclient should not be installed')
20+
except ImportError:
21+
pass
22+
23+
@pytest.mark.s3
24+
def test_s3_installed(self):
25+
try:
26+
import boto3 # noqa: F401
27+
except ImportError:
28+
raise Exception('boto3 should be installed')
29+
30+
@pytest.mark.no_s3
31+
def test_no_s3(self):
32+
try:
33+
import boto3 # noqa: F401
34+
raise Exception('boto3 should not be installed')
35+
except ImportError:
36+
pass

0 commit comments

Comments
 (0)