From f2bde833dbcf7661a59c3d8a39f6dfc63572d01a Mon Sep 17 00:00:00 2001 From: Mike Mindel Date: Mon, 15 Jan 2024 18:24:27 +0000 Subject: [PATCH] Convert project_root var to lower case Even though project_root will have a constant value, there's no benefit to capitalising it. My thinking hasn't settled on this yet, however intuitively it makes sense to keep it lower case unless there's a more compelling reason to capitalise it. I suspect that the upper case version of constants ("don't change these variables!") will end up closer to the code that uses them e.g. at the top of classes, i.e. as class variables. Or at the top of functions. In those instances, those variables (that shouldn't change) make more sense as lower case. Unless we're explicitly drawing attention to the fact they must not change. #tobediscussedfurther We've also added a "config.py" module to expose global variables like "project_root" to the rest of the app and not just in the tests. --- config.py | 5 +++++ tests/context.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 config.py diff --git a/config.py b/config.py new file mode 100644 index 0000000..dbb4deb --- /dev/null +++ b/config.py @@ -0,0 +1,5 @@ +import os +import sys + +project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.insert(0, project_root) diff --git a/tests/context.py b/tests/context.py index f14b0fc..8d6640b 100644 --- a/tests/context.py +++ b/tests/context.py @@ -1,7 +1,7 @@ import os import sys -PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) -sys.path.insert(0, PROJECT_ROOT) +project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.insert(0, project_root) from mylib import * # noqa: E402, F403