text
stringlengths 0
267k
|
---|
def _assert_certs_in_queue(self, mock_queue, expected_num): |
"""Check that the certificate generation task was added to the queue. """ |
certs_in_queue = [call_args[0] for (call_args, __) in mock_queue.call_args_list] |
self.assertEqual(len(certs_in_queue), expected_num) |
for cert in certs_in_queue: |
self.assertTrue(isinstance(cert, ExampleCertificate)) |
def _assert_cert_status(self, *expected_statuses): |
"""Check the example certificate status. """ |
actual_status = certs_api.example_certificates_status(self.COURSE_KEY) |
self.assertEqual(list(expected_statuses), actual_status) |
import os |
from .. import constants, logger |
from . import base_classes, io, api |
class Image(base_classes.BaseNode): |
"""Class the wraps an image node. This is the node that |
represent that actual file on disk. |
""" |
def __init__(self, node, parent): |
logger.debug("Image().__init__(%s)", node) |
base_classes.BaseNode.__init__(self, node, parent, constants.IMAGE) |
texture_folder = self.scene.options.get(constants.TEXTURE_FOLDER, "") |
self[constants.URL] = os.path.join(texture_folder, api.image.file_name(self.node)) |
@property |
def destination(self): |
""" |
:return: full destination path (when copied) |
""" |
dirname = os.path.dirname(self.scene.filepath) |
return os.path.join(dirname, self[constants.URL]) |
@property |
def filepath(self): |
""" |
:return: source file path |
""" |
return api.image.file_path(self.node) |
def copy_texture(self, func=io.copy): |
"""Copy the texture. |
self.filepath > self.destination |
:param func: Optional function override (Default value = io.copy) |
arguments are (<source>, <destination>) |
:return: path the texture was copied to |
""" |
logger.debug("Image().copy_texture()") |
func(self.filepath, self.destination) |
return self.destination |
# Test the runpy module |
import unittest |
import os |
import os.path |
import sys |
import re |
import tempfile |
import py_compile |
from test.support import forget, make_legacy_pyc, run_unittest, unload, verbose |
from test.script_helper import ( |
make_pkg, make_script, make_zip_pkg, make_zip_script, temp_dir) |
import runpy |
from runpy import _run_code, _run_module_code, run_module, run_path |
# Note: This module can't safely test _run_module_as_main as it |
# runs its tests in the current process, which would mess with the |
# real __main__ module (usually test.regrtest) |
# See test_cmd_line_script for a test that executes that code path |
# Set up the test code and expected results |
example_source = """\ |
# Check basic code execution |
result = ['Top level assignment'] |
def f(): |
result.append('Lower level reference') |
f() |
del f |
# Check the sys module |
import sys |
run_argv0 = sys.argv[0] |
run_name_in_sys_modules = __name__ in sys.modules |
module_in_sys_modules = (run_name_in_sys_modules and |
globals() is sys.modules[__name__].__dict__) |
# Check nested operation |
import runpy |
nested = runpy._run_module_code('x=1\\n', mod_name='<run>') |
""" |