Skip to content

Get coverage to 100% #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")