Skip to content

Commit

Permalink
Get coverage to 100% (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
pquentin committed May 4, 2020
1 parent 7a64280 commit b314d89
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_unasync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import errno
import io
import os
import shutil
Expand Down Expand Up @@ -72,6 +73,8 @@ def test_build_py_modules(tmpdir):
env = copy.copy(os.environ)
env["PYTHONPATH"] = os.path.realpath(os.path.join(TEST_DIR, ".."))
subprocess.check_call(["python", "setup.py", "build"], cwd=mod_dir, env=env)
# Calling it twice to test the "if not copied" branch
subprocess.check_call(["python", "setup.py", "build"], cwd=mod_dir, env=env)

unasynced = os.path.join(mod_dir, "build/lib/_sync/some_file.py")
tree_build_dir = list_files(mod_dir)
Expand Down Expand Up @@ -136,3 +139,13 @@ def test_project_structure_after_customized_build_py_packages(tmpdir):

with open(os.path.join(unasynced_dir_path, "tests/test_conn.py")) as f:
assert "import hip\n" in f.read()


def test_makedirs_existok(monkeypatch):
def raises(*args, **kwargs):
# Unexpected OSError
raise OSError(errno.EPERM, "Operation not permitted")

monkeypatch.setattr(os, "makedirs", raises)
with pytest.raises(OSError):
unasync._makedirs_existok("path")

0 comments on commit b314d89

Please sign in to comment.