lib: set version.TESTING based on if the unittest module is loaded

This is cleaner than needing to set an environment variable before
running unit tests.

Implements #28 (Check if unittest is loaded to determine if we are testing)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-12-26 13:05:08 -05:00
parent 2daefa932c
commit 10c5fd4cef
2 changed files with 3 additions and 2 deletions

View File

@ -37,4 +37,4 @@ pkgbuild:
.PHONY: tests
tests:
python tools/generate_tracks.py
EMMENTAL_TESTING=1 python -m unittest discover -v
python -m unittest discover -v

View File

@ -1,5 +1,6 @@
# Copyright 2021 (c) Anna Schumaker.
import os
import sys
MAJOR = 2
MINOR = 9
@ -10,7 +11,7 @@ if os.path.exists(".debug"):
if f.read().strip() == "emmental":
DEBUG = True
TESTING = os.environ.get("EMMENTAL_TESTING") != None
TESTING = "unittest" in sys.modules
def string():