def test_idempotent_any_syntatically_valid_python(src_contents: str) -> None: # Form feed char is detected by `pycln.utils.iou.safe_read`. if FORM_FEED_CHAR not in src_contents: # Before starting, let's confirm that the input string is valid Python: compile(src_contents, "<string>", "exec") # else the bug is in hypothesmith # Then format the code... configs = config.Config(paths=[Path("pycln/")], all_=True) reporter = report.Report(configs) session_maker = refactor.Refactor(configs, reporter) dst_contents = session_maker._code_session(src_contents) # After formatting, let's check that the ouput is valid Python: compile(dst_contents, "<string>", "exec")
def test_post_init(self, _check_regex, _check_path, init, config_): init.return_value = None configs = config.Config( paths=[Path(".")], config=config_, include=CONFIG["include"], exclude=CONFIG["exclude"], expand_stars=True, verbose=True, diff=True, all_=True, ) for attr, val in CONFIG.items(): if attr != "all": assert getattr(configs, attr) == val assert configs.paths == [Path(".")]
def test_post_init(self, _check_regex, _check_path, init, config_): init.return_value = None configs = config.Config( paths=[Path(".")], config=config_, include=DEFAULTS["include"], exclude=DEFAULTS["exclude"], extend_exclude=DEFAULTS["extend_exclude"], expand_stars=True, verbose=True, diff=True, all_=True, ) for attr in CONFIG_ATTR: if attr != "all": assert getattr(configs, attr) == DEFAULTS[attr] assert configs.paths == [Path(".")]
def setup_method(self, method): self.configs = config.Config(paths=[Path("")]) self.reporter = report.Report(self.configs) self.session_maker = refactor.Refactor(self.configs, self.reporter)
def setup_method(self, method): self.configs = config.Config(paths=[Path("")]) self.reporter = report.Report(self.configs) # Needed for some tests. self.alias = ast.alias(name="x", asname=None) self.impt = ImportFrom(NodeLocation((1, 0), 1), [self.alias], "xx", 1)
def test_check_path(self, _check_regex, paths, expec_paths): configs = config.Config(paths=paths) assert configs.paths == expec_paths
def setup_method(self, method, post_init, init): self.configs = config.Config(paths=[Path(".")])
def test_check_path_xfail(self, _check_regex, paths): with sysu.std_redirect(sysu.STD.ERR): config.Config(paths=paths)