Skip to content

Commit 7eccfd3

Browse files
committed
Add additional check to try to distingush between running tests on CI vs locally
1 parent 37d67d7 commit 7eccfd3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/conftest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def django_db_setup(django_db_setup, django_db_blocker):
3535
with django_db_blocker.unblock():
3636
qn = connection.ops.quote_name
3737

38+
db_user = settings.DATABASES[connection.alias]["USER"]
3839
db_hostname = settings.DATABASES[connection.alias]["HOST"]
3940

4041
with tempfile.TemporaryDirectory() as temp_dir:
@@ -45,9 +46,13 @@ def django_db_setup(django_db_setup, django_db_blocker):
4546
#
4647
# Note that this only typically works in CI environments
4748
# where we have utter control to execute arbitary commands.
48-
if db_hostname and db_hostname not in (
49-
"127.0.0.1",
50-
"localhost",
49+
if db_user or (
50+
db_hostname
51+
and db_hostname
52+
not in (
53+
"127.0.0.1",
54+
"localhost",
55+
)
5156
):
5257
cursor.execute(
5358
f"COPY (select 1) TO PROGRAM 'mkdir --mode=777 -p {temp_dir}'"

0 commit comments

Comments
 (0)