Replaced os.path in clic tests

This commit is contained in:
Angel Rey 2020-09-30 15:35:51 -05:00 committed by Cristian Vargas
parent 01461a98a7
commit 3e26ab3ce3

View file

@ -7,6 +7,7 @@ import os
import sys import sys
import shutil import shutil
import unittest import unittest
from pathlib import Path
from contextlib import contextmanager from contextlib import contextmanager
@ -109,13 +110,13 @@ class TestInit(unittest.TestCase):
with output_hidden(): with output_hidden():
archivebox_init.main([]) archivebox_init.main([])
assert os.path.exists(os.path.join(OUTPUT_DIR, SQL_INDEX_FILENAME)) assert (Path(OUTPUT_DIR) / SQL_INDEX_FILENAME).exists()
assert os.path.exists(os.path.join(OUTPUT_DIR, JSON_INDEX_FILENAME)) assert (Path(OUTPUT_DIR) / JSON_INDEX_FILENAME).exists()
assert os.path.exists(os.path.join(OUTPUT_DIR, HTML_INDEX_FILENAME)) assert (Path(OUTPUT_DIR) / HTML_INDEX_FILENAME).exists()
assert len(load_main_index(out_dir=OUTPUT_DIR)) == 0 assert len(load_main_index(out_dir=OUTPUT_DIR)) == 0
def test_conflicting_init(self): def test_conflicting_init(self):
with open(os.path.join(OUTPUT_DIR, 'test_conflict.txt'), 'w+') as f: with open(Path(OUTPUT_DIR) / 'test_conflict.txt', 'w+') as f:
f.write('test') f.write('test')
try: try:
@ -125,9 +126,9 @@ class TestInit(unittest.TestCase):
except SystemExit: except SystemExit:
pass pass
assert not os.path.exists(os.path.join(OUTPUT_DIR, SQL_INDEX_FILENAME)) assert not (Path(OUTPUT_DIR) / SQL_INDEX_FILENAME).exists()
assert not os.path.exists(os.path.join(OUTPUT_DIR, JSON_INDEX_FILENAME)) assert not (Path(OUTPUT_DIR) / JSON_INDEX_FILENAME).exists()
assert not os.path.exists(os.path.join(OUTPUT_DIR, HTML_INDEX_FILENAME)) assert not (Path(OUTPUT_DIR) / HTML_INDEX_FILENAME).exists()
try: try:
load_main_index(out_dir=OUTPUT_DIR) load_main_index(out_dir=OUTPUT_DIR)
assert False, 'load_main_index should raise an exception when no index is present' assert False, 'load_main_index should raise an exception when no index is present'
@ -159,7 +160,7 @@ class TestAdd(unittest.TestCase):
assert len(all_links) == 30 assert len(all_links) == 30
def test_add_arg_file(self): def test_add_arg_file(self):
test_file = os.path.join(OUTPUT_DIR, 'test.txt') test_file = Path(OUTPUT_DIR) / 'test.txt'
with open(test_file, 'w+') as f: with open(test_file, 'w+') as f:
f.write(test_urls) f.write(test_urls)