Skip to content

Commit 2b9aba8

Browse files
committed
some machines may not have tree command, and python3.7 does not work
with django 1.x (vs python2.7 does not work with django 2.x)
1 parent d52d3dc commit 2b9aba8

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

tests/test_django_project.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from unittest.mock import Mock, call
99

1010
import pytest
11+
1112
import pythonanywhere.django_project
1213
from pythonanywhere.django_project import DjangoProject
1314
from pythonanywhere.exceptions import SanityException
@@ -283,10 +284,13 @@ def test_updates_wsgi_file_from_template(self):
283284
def test_actually_produces_wsgi_file_that_can_import_project_non_nested(
284285
self, fake_home, non_nested_submodule, virtualenvs_folder
285286
):
286-
project = DjangoProject("mydomain.com", ".".join(python_version().split(".")[:2]))
287+
running_python_version = ".".join(python_version().split(".")[:2])
288+
project = DjangoProject("mydomain.com", running_python_version)
287289
shutil.copytree(str(non_nested_submodule), str(project.project_path))
288-
print(subprocess.check_call(["tree", str(project.project_path)]))
289-
project.create_virtualenv()
290+
if running_python_version == "3.7":
291+
project.create_virtualenv(django_version="latest")
292+
else:
293+
project.create_virtualenv()
290294
project.find_django_files()
291295
project.wsgi_file_path = Path(tempfile.NamedTemporaryFile().name)
292296

@@ -299,9 +303,13 @@ def test_actually_produces_wsgi_file_that_can_import_project_non_nested(
299303
def test_actually_produces_wsgi_file_that_can_import_nested_project(
300304
self, fake_home, more_nested_submodule, virtualenvs_folder
301305
):
302-
project = DjangoProject("mydomain.com", ".".join(python_version().split(".")[:2]))
306+
running_python_version = ".".join(python_version().split(".")[:2])
307+
project = DjangoProject("mydomain.com", running_python_version)
303308
shutil.copytree(str(more_nested_submodule), str(project.project_path))
304-
project.create_virtualenv()
309+
if running_python_version == "3.7":
310+
project.create_virtualenv(django_version="latest")
311+
else:
312+
project.create_virtualenv()
305313
project.find_django_files()
306314
project.wsgi_file_path = Path(tempfile.NamedTemporaryFile().name)
307315

tests/test_pa_start_django_webapp_with_virtualenv.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,16 @@ def test_nuke_option_lets_you_run_twice(self, fake_home, virtualenvs_folder, api
7373

7474
with patch("scripts.pa_start_django_webapp_with_virtualenv.DjangoProject.update_wsgi_file"):
7575
with patch("pythonanywhere.api.call_api"):
76-
version = ".".join(python_version().split(".")[:2])
77-
main("mydomain.com", "1.9.2", version, nuke=False)
78-
main("mydomain.com", "1.11.3", version, nuke=True)
76+
running_python_version = ".".join(python_version().split(".")[:2])
77+
if running_python_version[0] == 2:
78+
old_django_version = "1.9.2"
79+
new_django_version = "1.11.3"
80+
else:
81+
old_django_version = "2.0.8"
82+
new_django_version = "2.1.2"
83+
84+
main("mydomain.com", old_django_version, running_python_version, nuke=False)
85+
main("mydomain.com", new_django_version, running_python_version, nuke=True)
7986

8087
django_version = (
8188
subprocess.check_output(
@@ -87,4 +94,4 @@ def test_nuke_option_lets_you_run_twice(self, fake_home, virtualenvs_folder, api
8794
.decode()
8895
.strip()
8996
)
90-
assert django_version == "1.11.3"
97+
assert django_version == new_django_version

0 commit comments

Comments
 (0)