Fixed #19941 -- Modified runtests.py to make running the tests easier. #1352

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Owner

timgraham commented Jul 12, 2013

  1. Automatically use tests/../django as the Django version.
  2. If settings aren't provided through --settings or DJANGO_SETTINGS_MODULE)
    then use test_sqlite.

https://code.djangoproject.com/ticket/19941

@akaariai @timgraham akaariai Fixed #19941 -- Modified runtests.py to make running the tests easier.
1. Automatically use tests/../django as the Django version.
2. If settings aren't provided through --settings or DJANGO_SETTINGS_MODULE)
   then use test_sqlite.
93e2da1

@timgraham timgraham commented on the diff Jul 24, 2013

tests/runtests.py
@@ -7,6 +7,21 @@
import tempfile
import warnings
+def upath(path):
+ """
+ Separate version of django.utils._os.upath. The django.utils version isn't
+ usable here, as upath is needed for RUNTESTS_DIR which is needed for the
+ try-except of import django.
+ """
+ if sys.version_info[0] != 3 and not isinstance(path, bytes):
+ fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
+ return path.decode(fs_encoding)
+ return path
+
+RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
+sys.path.insert(0, os.path.dirname(RUNTESTS_DIR)) # 'tests/../'
+import django
@timgraham

timgraham Jul 24, 2013

Owner

@akaariai Could you comment on the purpose of this import? The docstring mentions a "try-except of import django." which seems to be missing - just wanted to check what you had in mind.

@akaariai

akaariai Jul 24, 2013

Member

I really don't remember. The comment might just be outdated.

@mjtamlyn

mjtamlyn Jul 24, 2013

Member

I can't see a need for it...

@akaariai

akaariai Jul 24, 2013

Member

Yeah, the import itself is very likely non-necessary, too.

timgraham closed this Jul 24, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment