def test_engrave_duped_scans(fileset_mutable, ok_files, f1_graft, f2_graft, caplog): caplog.set_level(0) fileset_mutable.chdir() cfg = Config() cfg.Project.pname = 'prj1' cfg.Project.current_version = '0.0.0' cfg.Project.version = '0.0.1' cfg.Project.engraves = [{ 'globs': ['/a/f*'], 'grafts': [f1_graft, f1_graft, f2_graft, f2_graft], }, { 'globs': ['b/f1', 'b/?3'], 'grafts': [f1_graft, f2_graft], }, ] prj1 = Project(config=cfg) cfg.Project.engraves = [{ 'globs': ['/a/f*', '/b/f2', 'b/?3'], 'grafts': [f1_graft, f2_graft], }] prj2 = Project(config=cfg) fproc = engrave.FileProcessor() fproc.scan_projects([prj1, prj2]) fproc.engrave_matches() #print(pformat(match_map)) assert fproc.nmatches() == 4 for fpath, text in ok_files.items(): ftxt = (fileset_mutable / fpath).read_text('utf-8') assert ftxt == tw.dedent(text)
def project2(): return Project(pname=pname2, pvtag_format='{pname}-V{version}', pvtag_regex=r"""(?xmi) ^(?P<pname>{pname}) - V(?P<version>\d[^-]*) (?:-(?P<descid>\d+-g[a-f\d]+))?$ """)
def test_YAMLable(): from polyvers.cli import PolyversCmd from polyvers.pvproject import Project, Engrave, Graft #assert Project in yu._get_yamel().representer.yaml_representers # @UndefinedVariable prj = Project(pname='a', basepath='b') pvcmd = PolyversCmd(projects=[prj]) ystr = yu.ydumps({'PolyversCmd': pvcmd}, trait_help=True, classes=[PolyversCmd, Project, Engrave, Graft]) print(ystr) assert ystr.startswith("PolyversCmd:") check_text(ystr, require=["#### regex ####", "regex: |-", "# #### globs ####"])
def test_Project_defaults(monorepocfg): proj = Project() assert proj.pvtag_format == '' assert proj.pvtag_regex == '' assert proj.tag_fnmatch() == '' proj = Project(config=monorepocfg) assert proj.pvtag_format == pvlib.pvtag_format assert proj.pvtag_regex == pvlib.pvtag_regex assert proj.tag_fnmatch() == '-v*'
def test_scan(fileset_mutable, orig_files, f1_graft, f2_graft, caplog): caplog.set_level(0) fileset_mutable.chdir() cfg = Config() cfg.Project.pname = 'prj1' cfg.Project.engraves = [{ 'globs': ['/a/f*', 'b/f1', '/b/f2', 'b/?3'], 'grafts': [f1_graft, f2_graft], }] prj = Project(config=cfg) fproc = engrave.FileProcessor() match_map = fproc.scan_projects([prj]) assert len(match_map) == 6 # nfiles #print(pformat(match_map)) assert fproc.nmatches() == 4 for fpath, text in orig_files.items(): ftxt = (fileset_mutable / fpath).read_text('utf-8') assert ftxt == tw.dedent(text)
def test_Project_regex_check(): with pytest.raises(trt.TraitError, match=r'missing \), unterminated subpattern'): Project(pvtag_regex="(")
def foo(monorepocfg): return Project(config=monorepocfg, pname='foo')
def project1(monorepocfg): return Project(config=monorepocfg, pname=pname1)