def test_egg_info_save_version_info_setup_defaults(self, tmpdir_cwd, env): """ When running save_version_info on an existing setup.cfg with the 'default' values present from a previous run, the file should remain unchanged, except on Python 2.6, where the order of the keys will be changed to match the order as found in a dictionary of those keys. """ setup_cfg = os.path.join(env.paths['home'], 'setup.cfg') build_files({ setup_cfg: DALS(""" [egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 """), }) dist = Distribution() ei = egg_info(dist) ei.initialize_options() ei.save_version_info(setup_cfg) with open(setup_cfg, 'r') as f: content = f.read() assert '[egg_info]' in content assert 'tag_build =' in content assert 'tag_date = 0' in content assert 'tag_svn_revision = 0' in content expected_order = 'tag_build', 'tag_date', 'tag_svn_revision' self._validate_content_order(content, expected_order)
def get_files(self): """Run egg_info and get all the files to include, as a set""" dist = Distribution(SETUP_ATTRS) dist.script_name = 'setup.py' cmd = egg_info(dist) cmd.ensure_finalized() cmd.run() return set(cmd.filelist.files)
def test_egg_info_includes_setup_py(self, tmpdir_cwd): self._create_project() dist = Distribution({"name": "foo", "version": "0.0.1"}) dist.script_name = "non_setup.py" egg_info_instance = egg_info(dist) egg_info_instance.finalize_options() egg_info_instance.run() assert 'setup.py' in egg_info_instance.filelist.files with open(egg_info_instance.egg_info + "/SOURCES.txt") as f: sources = f.read().split('\n') assert 'setup.py' in sources
def test_egg_info_save_version_info_setup_empty(self, tmpdir_cwd, env): """ When the egg_info section is empty or not present, running save_version_info should add the settings to the setup.cfg in a deterministic order. """ setup_cfg = os.path.join(env.paths['home'], 'setup.cfg') dist = Distribution() ei = egg_info(dist) ei.initialize_options() ei.save_version_info(setup_cfg) with open(setup_cfg, 'r') as f: content = f.read() assert '[egg_info]' in content assert 'tag_build =' in content assert 'tag_date = 0' in content expected_order = 'tag_build', 'tag_date', self._validate_content_order(content, expected_order)
def setUp(self): workingset = pkg_resources.working_set self.workingdir = os.getcwd() self.stored_syspath = copy(sys.path) test_packages = os.listdir(PROJECTS_DIR) self.added_entries = [] for package in test_packages: packagedir = os.path.join(PROJECTS_DIR, package) os.chdir(packagedir) dist = distutils.core.run_setup("setup.py") ei = egg_info(dist) ei.finalize_options() try: os.mkdir(ei.egg_info) except FileExistsError: pass ei.run() egginfodir = os.path.join(packagedir, "src") workingset.add_entry(egginfodir) self.added_entries.append(egginfodir) sys.path.append(egginfodir) os.chdir(self.workingdir)
def test_egg_info_save_version_info_setup_empty(self, tmpdir_cwd, env): """ When the egg_info section is empty or not present, running save_version_info should add the settings to the setup.cfg in a deterministic order, consistent with the ordering found on Python 2.7 with PYTHONHASHSEED=0. """ setup_cfg = os.path.join(env.paths['home'], 'setup.cfg') dist = Distribution() ei = egg_info(dist) ei.initialize_options() ei.save_version_info(setup_cfg) with open(setup_cfg, 'r') as f: content = f.read() assert '[egg_info]' in content assert 'tag_build =' in content assert 'tag_date = 0' in content expected_order = 'tag_build', 'tag_date', self._validate_content_order(content, expected_order)