tests: don't use var before assignment

```
repo_dir = <tests.basic_env.TestDirFixture object at 0x7f36c3f3d650>                  
git = <git.Repo "/tmp/dvc-test.2894.0LMoaT.eefefa48-172d-44e4-8c3d-4f65f76c78ee/.git">
                                                                                      
    @pytest.fixture                                                                   
    def dvc_repo(repo_dir, git):                                                      
        try:                                                                          
            dvc = DvcRepo.init(repo_dir._root_dir)                                    
            dvc.scm.commit("init dvc")                                                
            yield dvc                                                                 
        finally:                                                                      
>           dvc.scm.git.close()                                                       
E           UnboundLocalError: local variable 'dvc' referenced before assignment      
                                                                                      
/home/efiop/git/dvc/tests/conftest.py:76: UnboundLocalError                           
```
This commit is contained in:
Ruslan Kuprieiev
2019-06-06 13:44:13 +03:00
committed by GitHub
parent 67e6dc253a
commit f41dcea248
+3 -1
View File
@@ -68,12 +68,14 @@ def git(repo_dir):
@pytest.fixture
def dvc_repo(repo_dir, git):
dvc = None
try:
dvc = DvcRepo.init(repo_dir._root_dir)
dvc.scm.commit("init dvc")
yield dvc
finally:
dvc.scm.git.close()
if dvc:
dvc.scm.git.close()
here = os.path.abspath(os.path.dirname(__file__))