MCPcopy Create free account
hub / github.com/ipython/ipython / setUp

Method setUp

IPython/core/tests/test_run.py:443–466  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

441 f.write(textwrap.dedent(content))
442
443 def setUp(self):
444 self.package = package = 'tmp{0}'.format(''.join([random.choice(string.ascii_letters) for i in range(10)]))
445 """Temporary (probably) valid python package name."""
446
447 self.value = int(random.random() * 10000)
448
449 self.tempdir = TemporaryDirectory()
450 self.__orig_cwd = os.getcwd()
451 sys.path.insert(0, self.tempdir.name)
452
453 self.writefile(os.path.join(package, '__init__.py'), '')
454 self.writefile(os.path.join(package, 'sub.py'), """
455 x = {0!r}
456 """.format(self.value))
457 self.writefile(os.path.join(package, 'relative.py'), """
458 from .sub import x
459 """)
460 self.writefile(os.path.join(package, 'absolute.py'), """
461 from {0}.sub import x
462 """.format(package))
463 self.writefile(os.path.join(package, 'args.py'), """
464 import sys
465 a = " ".join(sys.argv[1:])
466 """.format(package))
467
468 def tearDown(self):
469 os.chdir(self.__orig_cwd)

Callers

nothing calls this directly

Calls 2

writefileMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected