8000 Minor style fixes by duggelz · Pull Request #69 · google/subpar · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Minor style fixes #69

Merged
merged 2 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ def lint(session):
session.install('flake8', 'flake8-import-order')
session.run(
'flake8',
'.',
'--import-order-style', 'google',
'compiler', 'runtime', 'tests',
'nox.py',
)
4 changes: 3 additions & 1 deletion runtime/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def _extract_files(archive_path):
Directory where contents were extracted to.
"""
extract_dir = tempfile.mkdtemp()

def _extract_files_cleanup():
shutil.rmtree(extract_dir, ignore_errors=True)
atexit.register(_extract_files_cleanup)
Expand Down Expand Up @@ -270,6 +271,7 @@ def find_eggs_and_dist_info_in_zip(importer, path_item, >
pkg_resources.working_set.add(dist, entry, insert=False,
replace=True)


def _initialize_import_path(import_roots, import_prefix):
"""Add extra entries to PYTHONPATH so that modules can be imported."""
# We try to match to order of Bazel's stub
Expand Down Expand Up @@ -313,7 +315,7 @@ def setup(import_roots, zip_safe):
# there for imports.
sys.path[0] = extract_dir
import_prefix = extract_dir
else: # Import directly from .par file
else: # Import directly from .par file
extract_dir = None
import_prefix = archive_path

Expand Down
16 changes: 10 additions & 6 deletions runtime/support_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import io
import os
import sys
import tempfile
import unittest
import zipfile

Expand Down Expand Up @@ -57,7 +56,8 @@ def setUpClass(cls):
cls.entry_data = entry_data

# Create mock loader object
class MockLoader(object): pass
class MockLoader(object):
pass
mock_loader = MockLoader()
mock_loader.archive = zipfile_name
mock_loader.prefix = ''
Expand Down Expand Up @@ -112,13 +112,16 @@ def test__extract_files(self):
self.assertEqual(actual_data, self.entry_data)

def test__version_check(self):
class MockModule(object): pass
class MockModule(object):
pass

class MockOldWorkingSet(object):
def add(self, dist, entry=None, insert=True): pass
def add(self, dist, entry=None, insert=True):
pass

class MockNewWorkingSet(object):
def add(self, dist, entry=None, insert=True, replace=False): pass
def add(self, dist, entry=None, insert=True, replace=False):
pass

pkg_resources = MockModule()
self.assertFalse(support._version_check_pkg_resources(pkg_resources))
Expand All @@ -136,7 +139,8 @@ def test_setup(self):
mock_sys_path = list(sys.path)
mock_sys_path[0] = self.zipfile_name
sys.path = mock_sys_path
success = support.setup(import_roots=['some_root', 'another_root'], zip_safe=True)
success = support.setup(import_roots=['some_root', 'another_root'],
zip_safe=True)
self.assertTrue(success)
finally:
sys.path = old_sys_path
Expand Down
1 change: 1 addition & 0 deletions tests/package_extract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ def main():
dat = pkgutil.get_data('extract_helper_package', 'extract_dat.txt')
assert (dat == b'Dummy data file for extract.py\n'), dat


if __name__ == '__main__':
main()
0