Skip to content

9th December 2021

Coding

Python

GitPython

Python Snippets

  • New: Copy a directory.

    import shutil
    
    shutil.copytree('bar', 'foo')
    
  • Correction: Use fixture to change the working directory of a test.

    The previous code didn't work, instead use the next fixture:

    @pytest.fixture(name="change_test_dir")
    def change_test_dir_(request: SubRequest) -> Any:
        os.chdir(request.fspath.dirname)
        yield
        os.chdir(request.config.invocation_dir)
    

DevOps

Automating Processes

cruft