From 10c5fd4cef4ce9ccd5523ecd4f2206e80f89b588 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 26 Dec 2021 13:05:08 -0500 Subject: [PATCH] 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 --- Makefile | 2 +- lib/version.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 80f18ba..57ca21e 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/lib/version.py b/lib/version.py index 4b475e7..0edd1b3 100644 --- a/lib/version.py +++ b/lib/version.py @@ -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():