|
1 | 1 | import logging
|
2 | 2 | import os
|
3 |
| -from os.path import join |
4 | 3 | from pathlib import Path
|
5 | 4 | import pytest
|
6 |
| -from shutil import rmtree |
7 | 5 | from typing import Optional
|
8 | 6 | from unittest import mock
|
9 | 7 |
|
@@ -89,32 +87,31 @@ def test_find_config_parent_dir(self, in_tmp_path: Path) -> None:
|
89 | 87 | """find_config cuba can find the config in the parent directory"""
|
90 | 88 | SCUBA_YML.write_text("image: bosybux")
|
91 | 89 |
|
92 |
| - os.mkdir("subdir") |
93 |
| - os.chdir("subdir") |
| 90 | + subdir = Path("subdir") |
| 91 | + subdir.mkdir() |
| 92 | + os.chdir(subdir) |
94 | 93 |
|
95 | 94 | # Verify our current working dir
|
96 |
| - assert_paths_equal(os.getcwd(), in_tmp_path.joinpath("subdir")) |
| 95 | + assert_paths_equal(Path.cwd(), in_tmp_path / subdir) |
97 | 96 |
|
98 | 97 | path, rel, _ = scuba.config.find_config()
|
99 | 98 | assert_paths_equal(path, in_tmp_path)
|
100 |
| - assert_paths_equal(rel, "subdir") |
| 99 | + assert_paths_equal(rel, subdir) |
101 | 100 |
|
102 | 101 | def test_find_config_way_up(self, in_tmp_path: Path) -> None:
|
103 | 102 | """find_config can find the config way up the directory hierarchy"""
|
104 | 103 | SCUBA_YML.write_text("image: bosybux")
|
105 | 104 |
|
106 |
| - subdirs = ["foo", "bar", "snap", "crackle", "pop"] |
107 |
| - |
108 |
| - for sd in subdirs: # TODO |
109 |
| - os.mkdir(sd) |
110 |
| - os.chdir(sd) |
| 105 | + subdir = Path("foo/bar/snap/crackle/pop") |
| 106 | + subdir.mkdir(parents=True) |
| 107 | + os.chdir(subdir) |
111 | 108 |
|
112 | 109 | # Verify our current working dir
|
113 |
| - assert_paths_equal(os.getcwd(), in_tmp_path.joinpath(*subdirs)) |
| 110 | + assert_paths_equal(Path.cwd(), in_tmp_path / subdir) |
114 | 111 |
|
115 | 112 | path, rel, _ = scuba.config.find_config()
|
116 | 113 | assert_paths_equal(path, in_tmp_path)
|
117 |
| - assert_paths_equal(rel, join(*subdirs)) |
| 114 | + assert_paths_equal(rel, subdir) |
118 | 115 |
|
119 | 116 | def test_find_config_nonexist(self) -> None:
|
120 | 117 | """find_config raises ConfigError if the config cannot be found"""
|
|
0 commit comments