Skip to content

Commit f497c3b

Browse files
committed
test: Use falsy values for test environment variables
* In particular, a test environment set to an empty string should evaluate to false * This falsyness will be needed for defaulting variables in the CI code. Signed-off-by: Ferenc Géczi <[email protected]>
1 parent 015e316 commit f497c3b

File tree

10 files changed

+17
-13
lines changed

10 files changed

+17
-13
lines changed

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
os.environ["INSTANA_TEST"] = "true"
88

9-
if 'GEVENT_TEST' in os.environ:
9+
if os.environ.get('GEVENT_TEST'):
1010
from gevent import monkey
1111
monkey.patch_all()
1212

tests/apps/aiohttp_app/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88

99
APP_THREAD = None
1010

11-
if 'GEVENT_TEST' not in os.environ and 'CASSANDRA_TEST' not in os.environ and sys.version_info >= (3, 5, 3):
11+
if not any((os.environ.get('GEVENT_TEST'),
12+
os.environ.get('CASSANDRA_TEST'),
13+
sys.version_info < (3, 5, 3))):
1214
APP_THREAD = launch_background_thread(server, "AIOHTTP")

tests/apps/flask_app/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
app_thread = None
99

10-
if 'CASSANDRA_TEST' not in os.environ and app_thread is None:
10+
if not os.environ('CASSANDRA_TEST') and app_thread is None:
1111
app_thread = launch_background_thread(server.serve_forever, "Flask")

tests/apps/grpc_server/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
import time
77
import threading
88

9-
if 'GEVENT_TEST' not in os.environ and 'CASSANDRA_TEST' not in os.environ and sys.version_info >= (3, 5, 3):
9+
if not any((os.environ.get('GEVENT_TEST'),
10+
os.environ.get('CASSANDRA_TEST'),
11+
sys.version_info < (3, 5, 3))):
1012
# Background RPC application
1113
#
1214
# Spawn the background RPC app that the tests will throw
@@ -19,4 +21,4 @@
1921
rpc_server_thread.name = "Background RPC app"
2022
print("Starting background RPC app...")
2123
rpc_server_thread.start()
22-
time.sleep(1)
24+
time.sleep(1)

tests/apps/pyramid_app/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
app_thread = None
99

10-
if 'CASSANDRA_TEST' not in os.environ:
10+
if not os.environ.get('CASSANDRA_TEST'):
1111
app_thread = launch_background_thread(server.serve_forever, "Pyramid")

tests/apps/tornado_server/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
app_thread = None
1010

11-
if app_thread is None and 'GEVENT_TEST' not in os.environ and 'CASSANDRA_TEST' not in os.environ:
11+
if not any((app_thread, os.environ.get('GEVENT_TEST'), os.environ.get('CASSANDRA_TEST')):
1212
testenv["tornado_port"] = 10813
1313
testenv["tornado_server"] = ("http://127.0.0.1:" + str(testenv["tornado_port"]))
1414

tests/clients/test_cassandra-driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
");")
3232

3333

34-
@pytest.mark.skipif("CASSANDRA_TEST" not in os.environ, reason="")
34+
@pytest.mark.skipif(not os.environ.get("CASSANDRA_TEST"), reason="")
3535
class TestCassandra(unittest.TestCase):
3636
def setUp(self):
3737
""" Clear all spans before a test run """

tests/clients/test_couchbase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
pass
3030

3131

32-
@pytest.mark.skipif("COUCHBASE_TEST" not in os.environ, reason="")
32+
@pytest.mark.skipif(not os.environ.get("COUCHBASE_TEST"), reason="")
3333
class TestStandardCouchDB(unittest.TestCase):
3434
def setup_class(self):
3535
""" Clear all spans before a test run """

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
# Cassandra and gevent tests are run in dedicated jobs on CircleCI and will
1111
# be run explicitly. (So always exclude them here)
12-
if "CASSANDRA_TEST" not in os.environ:
12+
if not os.environ.get("CASSANDRA_TEST" ):
1313
collect_ignore_glob.append("*test_cassandra*")
1414

15-
if "COUCHBASE_TEST" not in os.environ:
15+
if not os.environ.get("COUCHBASE_TEST"):
1616
collect_ignore_glob.append("*test_couchbase*")
1717

18-
if "GEVENT_TEST" not in os.environ:
18+
if not os.environ.get("GEVENT_TEST"):
1919
collect_ignore_glob.append("*test_gevent*")
2020

2121
# Python 3.10 support is incomplete yet

tests/frameworks/test_gevent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from opentracing.scope_managers.gevent import GeventScopeManager
1818

1919

20-
@pytest.mark.skipif("GEVENT_TEST" not in os.environ, reason="")
20+
@pytest.mark.skipif(not os.environ.get("GEVENT_TEST"), reason="")
2121
class TestGEvent(unittest.TestCase):
2222
def setUp(self):
2323
self.http = urllib3.HTTPConnectionPool('127.0.0.1', port=testenv["wsgi_port"], maxsize=20)

0 commit comments

Comments
 (0)