diff --git a/PyHardLinkBackup/__init__.py b/PyHardLinkBackup/__init__.py index adef096..f2d0113 100644 --- a/PyHardLinkBackup/__init__.py +++ b/PyHardLinkBackup/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.3.0" +__version__ = "0.3.1" import os os.environ["DJANGO_SETTINGS_MODULE"] = "PyHardLinkBackup.django_project.settings" diff --git a/PyHardLinkBackup/helper_cmd/phlb_run_unittests.cmd b/PyHardLinkBackup/helper_cmd/phlb_run_unittests.cmd index 613657e..444342d 100644 --- a/PyHardLinkBackup/helper_cmd/phlb_run_unittests.cmd +++ b/PyHardLinkBackup/helper_cmd/phlb_run_unittests.cmd @@ -34,6 +34,8 @@ echo on "%PIP_EXE%" install -r "%REQ_PATH%" "%PIP_EXE%" install --upgrade -r "%REQ_PATH%" +cd "%PKG_PATH%" +cd .. coverage.exe run --source=PyHardLinkBackup --parallel-mode -m nose PyHardLinkBackup --verbosity=2 @echo off if "%1" == "no_report" ( diff --git a/PyHardLinkBackup/tests/base.py b/PyHardLinkBackup/tests/base.py index e8d1ee3..dd10850 100644 --- a/PyHardLinkBackup/tests/base.py +++ b/PyHardLinkBackup/tests/base.py @@ -54,8 +54,11 @@ def setUp(self): ) def tearDown(self): - shutil.rmtree(self.temp_root_path) - os.mkdir(self.temp_root_path) + # FIXME: Under windows the root temp dir can't be deleted: + # PermissionError: [WinError 32] The process cannot access the file because it is being used by another process + def rmtree_error(function, path, excinfo): + print("Error remove temp: %r" % path) + shutil.rmtree(self.temp_root_path, ignore_errors=True, onerror=rmtree_error) def assert_click_exception(self, result): if result.exception: @@ -180,7 +183,7 @@ class BaseCreatedTwoBackupsTestCase(BaseCreatedOneBackupsTestCase): def setUp(self): super(BaseCreatedTwoBackupsTestCase, self).setUp() - + self.second_backup_result = self.invoke_cli("backup", self.source_path) self.second_run_path = self.get_newest_backup_path() @@ -190,7 +193,7 @@ def assert_first_backup(self): #print("\n".join(tree_list)) # pprint.pprint(tree_list,indent=0, width=200) self.assertEqual(tree_list, [self.first_run_path]+self.backuped_file_info) - + def assert_second_backup(self): fs_helper = UnittestFileSystemHelper() tree_list = fs_helper.pformat_tree(self.second_run_path, with_timestamps=False) diff --git a/PyHardLinkBackup/tests/utils.py b/PyHardLinkBackup/tests/utils.py index d46c251..b595be7 100644 --- a/PyHardLinkBackup/tests/utils.py +++ b/PyHardLinkBackup/tests/utils.py @@ -6,6 +6,10 @@ import sys +def force_posixpath(path): + return posixpath.normpath(path.replace(os.sep, "/")) + + class UnittestFileSystemHelper(object): DATETIME_FORMATTER="%Y%m%d:%H%M%S" @@ -29,7 +33,7 @@ def create_test_fs(self, fs_dict, dir=None): def pformat_tree(self, path, with_timestamps): def pformat_stat(path): - result = ["%-30s" % posixpath.normpath(path)] + result = ["%-30s" % force_posixpath(path)] stat = os.stat(path) if os.path.isfile(path): @@ -59,7 +63,7 @@ def pformat_stat(path): lines = [] for root, dirs, files in os.walk("."): if root == ".": - lines.append(posixpath.normpath(os.path.abspath(root))) + lines.append(os.path.abspath(root)) else: lines.append(pformat_stat(root)) @@ -87,4 +91,4 @@ def print_tree(self, path): "Please install the linux package 'tree' - Origin Error: %s" % err ) else: - raise NotImplementedError("TODO: %s" % sys.platform) \ No newline at end of file + raise NotImplementedError("TODO: %s" % sys.platform) diff --git a/README.creole b/README.creole index 3e11667..e602ffb 100644 --- a/README.creole +++ b/README.creole @@ -175,6 +175,8 @@ And then just request 'localhost' == History +* 15.01.2016 - v0.3.1 - [[https://github.com/jedie/PyHardLinkBackup/compare/v0.3.0...v0.3.1|compare v0.3.0...v0.3.1]] +** fix unittest run under windows * 15.01.2016 - v0.3.0 - [[https://github.com/jedie/PyHardLinkBackup/compare/v0.2.0...v0.3.0|compare v0.2.0...v0.3.0]] ** **database migration needed** ** Add 'no_link_source' to database (e.g. Skip source, if 1024 links created under windows) diff --git a/appveyor.yml b/appveyor.yml index e25b076..932ce97 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -91,12 +91,12 @@ test_script: - call phlb_run_unittests.cmd no_report on_finish: + - cd %APPDATA%/PyHardLinkBackup/src/pyhardlinkbackup - coverage combine + - coverage report - set COVERALLS_REPO_TOKEN=3uErcCZvScP0LKMj9qcgab67qRsu8XnSQ - coveralls - - coverage report - # http://www.appveyor.com/docs/how-to/rdp-to-build-worker #- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))