def test_staging(self): with self.env: self.env.set('QUARK_ENV', 'staging') settings = import_fresh_module('quark.settings') self.assertFalse(settings.DEBUG) self.assertEqual(settings.DATABASES, STAGING_DB)
def test_unset(self): with self.env: self.env.set('QUARK_ENV', 'dev') settings = import_fresh_module('quark.settings') self.assertTrue(settings.DEBUG) self.assertEqual(settings.DATABASES, DEV_DB)
def test_production(self): with self.env: self.env.set('QUARK_ENV', 'production') settings = import_fresh_module('quark.settings') self.assertFalse(settings.DEBUG) self.assertEqual(settings.DATABASES, PROD_DB)
def test_staging(self): with self.env: self.env.set("QUARK_ENV", "staging") settings = import_fresh_module("quark.settings") self.assertFalse(settings.DEBUG) self.assertEqual(settings.DATABASES, STAGING_DB)
def test_production(self): with self.env: self.env.set("QUARK_ENV", "production") settings = import_fresh_module("quark.settings") self.assertFalse(settings.DEBUG) self.assertEqual(settings.DATABASES, PROD_DB)
def test_unset(self): with self.env: self.env.set("QUARK_ENV", "dev") settings = import_fresh_module("quark.settings") self.assertTrue(settings.DEBUG) self.assertEqual(settings.DATABASES, DEV_DB)
"""Unittests for heapq.""" import random import unittest from test import test_support import sys # We do a bit of trickery here to be able to test both the C implementation # and the Python implementation of the module. import heapq as c_heapq py_heapq = test_support.import_fresh_module('heapq', blocked=['_heapq']) class TestHeap(unittest.TestCase): module = None def test_push_pop(self): # 1) Push 256 random numbers and pop them off, verifying all's OK. heap = [] data = [] self.check_invariant(heap) for i in range(256): item = random.random() data.append(item) self.module.heappush(heap, item) self.check_invariant(heap) results = [] while heap: item = self.module.heappop(heap) self.check_invariant(heap) results.append(item) data_sorted = data[:]
import os import sys import doctest import unittest from test import test_support from pykit import p3json # import json with and without accelerations cjson = test_support.import_fresh_module('json', fresh=['_json']) # pyjson = test_support.import_fresh_module('json', blocked=['_json']) pyjson = p3json # create two base classes that will be used by the other tests class PyTest(unittest.TestCase): json = pyjson loads = staticmethod(pyjson.loads) dumps = staticmethod(pyjson.dumps) # test PyTest and CTest checking if the functions come from the right module class TestPyTest(PyTest): def test_pyjson(self): self.assertEqual(self.json.scanner.make_scanner.__module__, 'json.scanner') self.assertEqual(self.json.decoder.scanstring.__module__, 'json.decoder') self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__, 'json.encoder') here = os.path.dirname(__file__)
"""Unittests for heapq.""" import sys import random from test import test_support from unittest import TestCase, skipUnless py_heapq = test_support.import_fresh_module("heapq", blocked=["_heapq"]) c_heapq = test_support.import_fresh_module("heapq", fresh=["_heapq"]) # _heapq.nlargest/nsmallest are saved in heapq._nlargest/_smallest when # _heapq is imported, so check them there func_names = ["heapify", "heappop", "heappush", "heappushpop", "heapreplace", "_nlargest", "_nsmallest"] class TestModules(TestCase): def test_py_functions(self): for fname in func_names: self.assertEqual(getattr(py_heapq, fname).__module__, "heapq") @skipUnless(c_heapq, "requires _heapq") def test_c_functions(self): for fname in func_names: self.assertEqual(getattr(c_heapq, fname).__module__, "_heapq") class TestHeap(TestCase): module = None def test_push_pop(self):
from contextlib import contextmanager import linecache import os import StringIO import sys import unittest import subprocess from test import test_support from test.script_helper import assert_python_ok import warning_tests import warnings as original_warnings py_warnings = test_support.import_fresh_module('warnings', blocked=['_warnings']) c_warnings = test_support.import_fresh_module('warnings', fresh=['_warnings']) @contextmanager def warnings_state(module): """Use a specific warnings implementation in warning_tests.""" global __warningregistry__ for to_clear in (sys, warning_tests): try: to_clear.__warningregistry__.clear() except AttributeError: pass try: __warningregistry__.clear() except NameError:
# 2016.02.14 12:48:45 Støední Evropa (bìžný èas) # Embedded file name: scripts/common/Lib/json/tests/__init__.py import os import sys import json import doctest import unittest from test import test_support cjson = test_support.import_fresh_module("json", fresh=["_json"]) pyjson = test_support.import_fresh_module("json", blocked=["_json"]) class PyTest(unittest.TestCase): json = pyjson loads = staticmethod(pyjson.loads) dumps = staticmethod(pyjson.dumps) @unittest.skipUnless(cjson, "requires _json") class CTest(unittest.TestCase): if cjson is not None: json = cjson loads = staticmethod(cjson.loads) dumps = staticmethod(cjson.dumps) class TestPyTest(PyTest): def test_pyjson(self): self.assertEqual(self.json.scanner.make_scanner.__module__, "json.scanner") self.assertEqual(self.json.decoder.scanstring.__module__, "json.decoder")
import unittest import sys import os from test import test_support from subprocess import Popen, PIPE # Skip this test if the _tkinter module wasn't built. _tkinter = test_support.import_module('_tkinter') # Make sure tkinter._fix runs to set up the environment tkinter = test_support.import_fresh_module('Tkinter') from Tkinter import Tcl from _tkinter import TclError try: from _testcapi import INT_MAX, PY_SSIZE_T_MAX except ImportError: INT_MAX = PY_SSIZE_T_MAX = sys.maxsize tcl_version = _tkinter.TCL_VERSION.split('.') try: for i in range(len(tcl_version)): tcl_version[i] = int(tcl_version[i]) except ValueError: pass tcl_version = tuple(tcl_version) _tk_patchlevel = None def get_tk_patchlevel(): global _tk_patchlevel
import unittest import re import sys import os from test import test_support from subprocess import Popen, PIPE # Skip this test if the _tkinter module wasn't built. _tkinter = test_support.import_module('_tkinter') # Make sure tkinter._fix runs to set up the environment tkinter = test_support.import_fresh_module('Tkinter') from Tkinter import Tcl from _tkinter import TclError try: from _testcapi import INT_MAX, PY_SSIZE_T_MAX except ImportError: INT_MAX = PY_SSIZE_T_MAX = sys.maxsize tcl_version = tuple(map(int, _tkinter.TCL_VERSION.split('.'))) _tk_patchlevel = None def get_tk_patchlevel(): global _tk_patchlevel if _tk_patchlevel is None: tcl = Tcl() patchlevel = tcl.call('info', 'patchlevel') m = re.match(r'(\d+)\.(\d+)([ab.])(\d+)$', patchlevel) major, minor, releaselevel, serial = m.groups()
from contextlib import contextmanager import linecache import os import StringIO import sys import unittest import subprocess from test import test_support from test.script_helper import assert_python_ok import warning_tests import warnings as original_warnings py_warnings = test_support.import_fresh_module('warnings', blocked=['_warnings']) c_warnings = test_support.import_fresh_module('warnings', fresh=['_warnings']) @contextmanager def warnings_state(module): """Use a specific warnings implementation in warning_tests.""" global __warningregistry__ for to_clear in (sys, warning_tests): try: to_clear.__warningregistry__.clear() except AttributeError: pass try: __warningregistry__.clear() except NameError: pass original_warnings = warning_tests.warnings
# Python bytecode 2.7 (decompiled from Python 2.7) # Embedded file name: scripts/common/Lib/json/tests/__init__.py import os import sys import json import doctest import unittest from test import test_support cjson = test_support.import_fresh_module('json', fresh=['_json']) pyjson = test_support.import_fresh_module('json', blocked=['_json']) class PyTest(unittest.TestCase): json = pyjson loads = staticmethod(pyjson.loads) dumps = staticmethod(pyjson.dumps) @unittest.skipUnless(cjson, 'requires _json') class CTest(unittest.TestCase): if cjson is not None: json = cjson loads = staticmethod(cjson.loads) dumps = staticmethod(cjson.dumps) class TestPyTest(PyTest): def test_pyjson(self): self.assertEqual(self.json.scanner.make_scanner.__module__, 'json.scanner') self.assertEqual(self.json.decoder.scanstring.__module__,
"""Unittests for heapq.""" import random import unittest from test import test_support import sys # We do a bit of trickery here to be able to test both the C implementation # and the Python implementation of the module. import heapq as c_heapq py_heapq = test_support.import_fresh_module('heapq', blocked=['_heapq']) class TestHeap(unittest.TestCase): module = None def test_push_pop(self): # 1) Push 256 random numbers and pop them off, verifying all's OK. heap = [] data = [] self.check_invariant(heap) for i in range(256): item = random.random() data.append(item) self.module.heappush(heap, item) self.check_invariant(heap) results = [] while heap: item = self.module.heappop(heap) self.check_invariant(heap) results.append(item)
from contextlib import contextmanager import linecache import os import StringIO import sys import unittest import subprocess from test import test_support from test.script_helper import assert_python_ok import warning_tests import warnings as original_warnings py_warnings = test_support.import_fresh_module("warnings", blocked=["_warnings"]) c_warnings = test_support.import_fresh_module("warnings", fresh=["_warnings"]) @contextmanager def warnings_state(module): """Use a specific warnings implementation in warning_tests.""" global __warningregistry__ for to_clear in (sys, warning_tests): try: to_clear.__warningregistry__.clear() except AttributeError: pass try: __warningregistry__.clear() except NameError: pass
# 2015.11.10 21:36:31 Støední Evropa (bìžný èas) # Embedded file name: scripts/common/Lib/json/tests/__init__.py import os import sys import json import doctest import unittest from test import test_support cjson = test_support.import_fresh_module('json', fresh=['_json']) pyjson = test_support.import_fresh_module('json', blocked=['_json']) class PyTest(unittest.TestCase): json = pyjson loads = staticmethod(pyjson.loads) dumps = staticmethod(pyjson.dumps) @unittest.skipUnless(cjson, 'requires _json') class CTest(unittest.TestCase): if cjson is not None: json = cjson loads = staticmethod(cjson.loads) dumps = staticmethod(cjson.dumps) class TestPyTest(PyTest): def test_pyjson(self): self.assertEqual(self.json.scanner.make_scanner.__module__, 'json.scanner') self.assertEqual(self.json.decoder.scanstring.__module__, 'json.decoder')
import os import sys import doctest import unittest from test import test_support from pykit import p3json # import json with and without accelerations cjson = test_support.import_fresh_module('json', fresh=['_json']) # pyjson = test_support.import_fresh_module('json', blocked=['_json']) pyjson = p3json # create two base classes that will be used by the other tests class PyTest(unittest.TestCase): json = pyjson loads = staticmethod(pyjson.loads) dumps = staticmethod(pyjson.dumps) # test PyTest and CTest checking if the functions come from the right module class TestPyTest(PyTest): def test_pyjson(self): self.assertEqual(self.json.scanner.make_scanner.__module__, 'json.scanner') self.assertEqual(self.json.decoder.scanstring.__module__, 'json.decoder') self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__, 'json.encoder')