Skip to content

Commit

Permalink
Convert project_root var to lower case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
webventurer committed Jan 15, 2024
1 parent 336a6da commit f2bde83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions tests/context.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f2bde83

Please sign in to comment.