Python email.__file__() Examples
The following are 30
code examples of email.__file__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
email
, or try the search function
.
Example #1
Source File: test_zipfile.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_write_pyfile(self): self.requiresWriteAccess(os.path.dirname(__file__)) with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] zipfp.writepy(fn) bn = os.path.basename(fn) self.assertNotIn(bn, zipfp.namelist()) self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: fn = __file__ if fn.endswith(('.pyc', '.pyo')): fn = fn[:-1] zipfp.writepy(fn, "testpackage") bn = "%s/%s" % ("testpackage", os.path.basename(fn)) self.assertNotIn(bn, zipfp.namelist()) self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
Example #2
Source File: test_zipfile.py From BinderFilter with MIT License | 6 votes |
def test_write_pyfile(self): with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] zipfp.writepy(fn) bn = os.path.basename(fn) self.assertNotIn(bn, zipfp.namelist()) self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: fn = __file__ if fn.endswith(('.pyc', '.pyo')): fn = fn[:-1] zipfp.writepy(fn, "testpackage") bn = "%s/%s" % ("testpackage", os.path.basename(fn)) self.assertNotIn(bn, zipfp.namelist()) self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
Example #3
Source File: test_zipfile.py From oss-ftp with MIT License | 6 votes |
def test_write_pyfile(self): with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] zipfp.writepy(fn) bn = os.path.basename(fn) self.assertNotIn(bn, zipfp.namelist()) self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: fn = __file__ if fn.endswith(('.pyc', '.pyo')): fn = fn[:-1] zipfp.writepy(fn, "testpackage") bn = "%s/%s" % ("testpackage", os.path.basename(fn)) self.assertNotIn(bn, zipfp.namelist()) self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
Example #4
Source File: test_zipfile.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_write_pyfile(self): with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] zipfp.writepy(fn) bn = os.path.basename(fn) self.assertNotIn(bn, zipfp.namelist()) self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: fn = __file__ if fn.endswith(('.pyc', '.pyo')): fn = fn[:-1] zipfp.writepy(fn, "testpackage") bn = "%s/%s" % ("testpackage", os.path.basename(fn)) self.assertNotIn(bn, zipfp.namelist()) self.assertTrue(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist())
Example #5
Source File: test_zipfile.py From ironpython3 with Apache License 2.0 | 6 votes |
def test_write_with_optimization(self): import email packagedir = os.path.dirname(email.__file__) self.requiresWriteAccess(packagedir) # use .pyc if running test in optimization mode, # use .pyo if running test in debug mode optlevel = 1 if __debug__ else 0 ext = '.pyo' if optlevel == 1 else '.pyc' with TemporaryFile() as t, \ zipfile.PyZipFile(t, "w", optimize=optlevel) as zipfp: zipfp.writepy(packagedir) names = zipfp.namelist() self.assertIn('email/__init__' + ext, names) self.assertIn('email/mime/text' + ext, names)
Example #6
Source File: test_email_torture.py From medicare-demo with Apache License 2.0 | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro
Example #7
Source File: test_zipfile.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testWritePythonPackage(self): import email packagedir = os.path.dirname(email.__file__) zipfp = zipfile.PyZipFile(TemporaryFile(), "w") zipfp.writepy(packagedir) # Check for a couple of modules at different levels of the hieararchy names = zipfp.namelist() if not is_jython: self.assert_('email/__init__.pyo' in names or 'email/__init__.pyc' in names) self.assert_('email/mime/text.pyo' in names or 'email/mime/text.pyc' in names) else: self.assert_('email/__init__$py.class' in names) self.assert_('email/mime/text$py.class' in names)
Example #8
Source File: test_zipfile.py From medicare-demo with Apache License 2.0 | 5 votes |
def testWritePyfile(self): zipfp = zipfile.PyZipFile(TemporaryFile(), "w") fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] elif fn.endswith('$py.class'): fn = fn[:-9] + '.py' zipfp.writepy(fn) bn = os.path.basename(fn) self.assert_(bn not in zipfp.namelist()) if not is_jython: self.assert_(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) else: self.assert_(bn[:-3] + '$py.class' in zipfp.namelist()) zipfp.close() zipfp = zipfile.PyZipFile(TemporaryFile(), "w") fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] elif fn.endswith('$py.class'): fn = fn[:-9] + '.py' zipfp.writepy(fn, "testpackage") bn = "%s/%s"%("testpackage", os.path.basename(fn)) self.assert_(bn not in zipfp.namelist()) if not is_jython: self.assert_(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) else: self.assert_(bn[:-3] + '$py.class' in zipfp.namelist()) zipfp.close()
Example #9
Source File: test_zipfile.py From medicare-demo with Apache License 2.0 | 5 votes |
def testWritePythonPackage(self): import email packagedir = os.path.dirname(email.__file__) zipfp = zipfile.PyZipFile(TemporaryFile(), "w") zipfp.writepy(packagedir) # Check for a couple of modules at different levels of the hieararchy names = zipfp.namelist() if not is_jython: self.assert_('email/__init__.pyo' in names or 'email/__init__.pyc' in names) self.assert_('email/mime/text.pyo' in names or 'email/mime/text.pyc' in names) else: self.assert_('email/__init__$py.class' in names) self.assert_('email/mime/text$py.class' in names)
Example #10
Source File: test_email_torture.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro
Example #11
Source File: test_email_torture.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro
Example #12
Source File: test_zipfile.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testWritePyfile(self): zipfp = zipfile.PyZipFile(TemporaryFile(), "w") fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] elif fn.endswith('$py.class'): fn = fn[:-9] + '.py' zipfp.writepy(fn) bn = os.path.basename(fn) self.assert_(bn not in zipfp.namelist()) if not is_jython: self.assert_(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) else: self.assert_(bn[:-3] + '$py.class' in zipfp.namelist()) zipfp.close() zipfp = zipfile.PyZipFile(TemporaryFile(), "w") fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] elif fn.endswith('$py.class'): fn = fn[:-9] + '.py' zipfp.writepy(fn, "testpackage") bn = "%s/%s"%("testpackage", os.path.basename(fn)) self.assert_(bn not in zipfp.namelist()) if not is_jython: self.assert_(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) else: self.assert_(bn[:-3] + '$py.class' in zipfp.namelist()) zipfp.close()
Example #13
Source File: test_zipfile.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def testWritePythonPackage(self): import email packagedir = os.path.dirname(email.__file__) zipfp = zipfile.PyZipFile(TemporaryFile(), "w") zipfp.writepy(packagedir) # Check for a couple of modules at different levels of the hieararchy names = zipfp.namelist() if not is_jython: self.assert_('email/__init__.pyo' in names or 'email/__init__.pyc' in names) self.assert_('email/mime/text.pyo' in names or 'email/mime/text.pyc' in names) else: self.assert_('email/__init__$py.class' in names) self.assert_('email/mime/text$py.class' in names)
Example #14
Source File: torture_test.py From android_universal with MIT License | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro
Example #15
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_write_pyfile(self): self.requiresWriteAccess(os.path.dirname(__file__)) with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: fn = __file__ if fn.endswith('.pyc'): path_split = fn.split(os.sep) if os.altsep is not None: path_split.extend(fn.split(os.altsep)) if '__pycache__' in path_split: fn = importlib.util.source_from_cache(fn) else: fn = fn[:-1] zipfp.writepy(fn) bn = os.path.basename(fn) self.assertNotIn(bn, zipfp.namelist()) self.assertCompiledIn(bn, zipfp.namelist()) with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: fn = __file__ if fn.endswith('.pyc'): fn = fn[:-1] zipfp.writepy(fn, "testpackage") bn = "%s/%s" % ("testpackage", os.path.basename(fn)) self.assertNotIn(bn, zipfp.namelist()) self.assertCompiledIn(bn, zipfp.namelist())
Example #16
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_write_python_package(self): import email packagedir = os.path.dirname(email.__file__) self.requiresWriteAccess(packagedir) with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: zipfp.writepy(packagedir) # Check for a couple of modules at different levels of the # hierarchy names = zipfp.namelist() self.assertCompiledIn('email/__init__.py', names) self.assertCompiledIn('email/mime/text.py', names)
Example #17
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_write_filtered_python_package(self): import test packagedir = os.path.dirname(test.__file__) self.requiresWriteAccess(packagedir) with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: # first make sure that the test folder gives error messages # (on the badsyntax_... files) with captured_stdout() as reportSIO: zipfp.writepy(packagedir) reportStr = reportSIO.getvalue() self.assertTrue('SyntaxError' in reportStr) # then check that the filter works on the whole package with captured_stdout() as reportSIO: zipfp.writepy(packagedir, filterfunc=lambda whatever: False) reportStr = reportSIO.getvalue() self.assertTrue('SyntaxError' not in reportStr) # then check that the filter works on individual files def filter(path): return not os.path.basename(path).startswith("bad") with captured_stdout() as reportSIO, self.assertWarns(UserWarning): zipfp.writepy(packagedir, filterfunc=filter) reportStr = reportSIO.getvalue() if reportStr: print(reportStr) self.assertTrue('SyntaxError' not in reportStr)
Example #18
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_write_with_optimization(self): import email packagedir = os.path.dirname(email.__file__) self.requiresWriteAccess(packagedir) optlevel = 1 if __debug__ else 0 ext = '.pyc' with TemporaryFile() as t, \ zipfile.PyZipFile(t, "w", optimize=optlevel) as zipfp: zipfp.writepy(packagedir) names = zipfp.namelist() self.assertIn('email/__init__' + ext, names) self.assertIn('email/mime/text' + ext, names)
Example #19
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_from_file(self): zi = zipfile.ZipInfo.from_file(__file__) self.assertEqual(posixpath.basename(zi.filename), 'test_zipfile.py') self.assertFalse(zi.is_dir()) self.assertEqual(zi.file_size, os.path.getsize(__file__))
Example #20
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_from_file_pathlike(self): zi = zipfile.ZipInfo.from_file(pathlib.Path(__file__)) self.assertEqual(posixpath.basename(zi.filename), 'test_zipfile.py') self.assertFalse(zi.is_dir()) self.assertEqual(zi.file_size, os.path.getsize(__file__))
Example #21
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_from_file_bytes(self): zi = zipfile.ZipInfo.from_file(os.fsencode(__file__), 'test') self.assertEqual(posixpath.basename(zi.filename), 'test') self.assertFalse(zi.is_dir()) self.assertEqual(zi.file_size, os.path.getsize(__file__))
Example #22
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_from_file_fileno(self): with open(__file__, 'rb') as f: zi = zipfile.ZipInfo.from_file(f.fileno(), 'test') self.assertEqual(posixpath.basename(zi.filename), 'test') self.assertFalse(zi.is_dir()) self.assertEqual(zi.file_size, os.path.getsize(__file__))
Example #23
Source File: test_zipfile.py From android_universal with MIT License | 5 votes |
def test_from_dir(self): dirpath = os.path.dirname(os.path.abspath(__file__)) zi = zipfile.ZipInfo.from_file(dirpath, 'stdlib_tests') self.assertEqual(zi.filename, 'stdlib_tests/') self.assertTrue(zi.is_dir()) self.assertEqual(zi.compress_type, zipfile.ZIP_STORED) self.assertEqual(zi.file_size, 0)
Example #24
Source File: test_email_torture.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro
Example #25
Source File: test_email_torture.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro
Example #26
Source File: test_zipfile.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def testWritePyfile(self): zipfp = zipfile.PyZipFile(TemporaryFile(), "w") fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] elif fn.endswith('$py.class'): fn = fn[:-9] + '.py' zipfp.writepy(fn) bn = os.path.basename(fn) self.assert_(bn not in zipfp.namelist()) if not is_jython: self.assert_(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) else: self.assert_(bn[:-3] + '$py.class' in zipfp.namelist()) zipfp.close() zipfp = zipfile.PyZipFile(TemporaryFile(), "w") fn = __file__ if fn.endswith('.pyc') or fn.endswith('.pyo'): fn = fn[:-1] elif fn.endswith('$py.class'): fn = fn[:-9] + '.py' zipfp.writepy(fn, "testpackage") bn = "%s/%s"%("testpackage", os.path.basename(fn)) self.assert_(bn not in zipfp.namelist()) if not is_jython: self.assert_(bn + 'o' in zipfp.namelist() or bn + 'c' in zipfp.namelist()) else: self.assert_(bn[:-3] + '$py.class' in zipfp.namelist()) zipfp.close()
Example #27
Source File: test_email_torture.py From ironpython2 with Apache License 2.0 | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro
Example #28
Source File: torture_test.py From ironpython3 with Apache License 2.0 | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro
Example #29
Source File: test_zipfile.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_write_python_package(self): import email packagedir = os.path.dirname(email.__file__) self.requiresWriteAccess(packagedir) with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: zipfp.writepy(packagedir) # Check for a couple of modules at different levels of the # hierarchy names = zipfp.namelist() self.assertTrue('email/__init__.pyo' in names or 'email/__init__.pyc' in names) self.assertTrue('email/mime/text.pyo' in names or 'email/mime/text.pyc' in names)
Example #30
Source File: test_email_torture.py From BinderFilter with MIT License | 5 votes |
def openfile(filename): from os.path import join, dirname, abspath path = abspath(join(dirname(testfile), os.pardir, 'moredata', filename)) return open(path, 'r') # Prevent this test from running in the Python distro