Skip to content

test: erepo_dir bootstrapping is bloaty  #2967

@Suor

Description

@Suor

To simply create a dvc or git controlled foo you need to:

def test_someting(erepo_dir, monkeypatch):
    # for dvc
    with monkeypatch.context() as m:
        m.chdir(erepo_dir)
        erepo_dir.dvc_gen("foo", "foo")

    # for git
    with monkeypatch.context() as m:
        m.chdir(erepo_dir)
        erepo_dir.scm_gen("foo", "foo", commit="add foo")

Which is far more bloaty then for tmp_dir. See here how @pared is struggling with it)

I see two options:

  1. Make it work without chdir:

    erepo_dir.dvc_gen("foo", "foo")    

    This will, however, bring an assymetry:

    # creates erepo_dir / foo
    erepo_dir.gen("foo", "foo")    
    
    # dvc adds erepo_dir / foo
    erepo_dir.dvc_add("foo")    
    
    # dvc adds <curdir> / foo
    erepo_dir.dvc.add("foo")    

    We don't really want to wrap scm and dvc objects.

  2. Use chdir but make it simpler:

    def test_someting(erepo_dir):
        with erepo_dir.chdir():
            erepo_dir.dvc_gen("foo", "foo")

    Saved one line, no need to add monkeypatch to args, still have nesting and an extra line compared to option 1. Retain symmetry, may use scm and dvc with relpaths in the context.

What do you guys think? @pared, @efiop, @MrOutis?

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-nice-to-haveIt should be done this or next sprintrefactoringFactoring and re-factoringtestingRelated to the tests and the testing infrastructure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions