Mercurial > piecrust2
changeset 286:a2d283d1033d
tests: Fixes for running on Windows.
Mostly about those damn backslashes, as usual.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 04 Mar 2015 22:40:50 -0800 |
parents | 6e9b5530306e |
children | 7081a5f88e10 |
files | piecrust/baking/single.py piecrust/sources/autoconfig.py tests/pathutil.py tests/test_baking_baker.py tests/test_sources_autoconfig.py tests/test_sources_base.py |
diffstat | 6 files changed, 27 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/baking/single.py Mon Mar 02 22:42:16 2015 -0800 +++ b/piecrust/baking/single.py Wed Mar 04 22:40:50 2015 -0800 @@ -150,7 +150,7 @@ try: in_path_time = record_entry.path_mtime out_path_time = os.path.getmtime(out_path) - if out_path_time > in_path_time: + if out_path_time >= in_path_time: do_bake = False except OSError: # File doesn't exist, we'll need to bake.
--- a/piecrust/sources/autoconfig.py Mon Mar 02 22:42:16 2015 -0800 +++ b/piecrust/sources/autoconfig.py Wed Mar 04 22:40:50 2015 -0800 @@ -186,7 +186,7 @@ """ SOURCE_NAME = 'ordered' - re_pattern = re.compile(r'(^|/)(?P<num>\d+)_') + re_pattern = re.compile(r'(^|[/\\])(?P<num>\d+)_') def __init__(self, app, name, config): config['capture_mode'] = 'path'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/pathutil.py Wed Mar 04 22:40:50 2015 -0800 @@ -0,0 +1,13 @@ +import os + + +def slashfix(path): + if path is None: + return None + if isinstance(path, str): + return path.replace('/', os.sep) + fixed = [] + for p in path: + fixed.append(p.replace('/', os.sep)) + return fixed +
--- a/tests/test_baking_baker.py Mon Mar 02 22:42:16 2015 -0800 +++ b/tests/test_baking_baker.py Wed Mar 04 22:40:50 2015 -0800 @@ -1,3 +1,4 @@ +import time import os.path import pytest from piecrust.baking.baker import PageBaker, Baker @@ -105,6 +106,7 @@ baker = Baker(app, out_dir) baker.bake() mtime = os.path.getmtime(fs.path('kitchen/_counter/foo.html')) + time.sleep(1) app = fs.getApp() baker = Baker(app, out_dir)
--- a/tests/test_sources_autoconfig.py Mon Mar 02 22:42:16 2015 -0800 +++ b/tests/test_sources_autoconfig.py Wed Mar 04 22:40:50 2015 -0800 @@ -1,6 +1,7 @@ import pytest from piecrust.sources.base import MODE_PARSING from .mockutil import mock_fs, mock_fs_scope +from .pathutil import slashfix @pytest.mark.parametrize( @@ -64,7 +65,7 @@ s = app.getSource('test') facs = list(s.buildPageFactories()) paths = [f.rel_path for f in facs] - assert paths == expected_paths + assert paths == slashfix(expected_paths) metadata = [f.metadata for f in facs] assert metadata == expected_metadata @@ -123,7 +124,7 @@ s = app.getSource('test') facs = list(s.buildPageFactories()) paths = [f.rel_path for f in facs] - assert paths == expected_paths + assert paths == slashfix(expected_paths) metadata = [f.metadata for f in facs] assert metadata == expected_metadata @@ -173,6 +174,6 @@ s = app.getSource('test') route_metadata = {'slug': route_path} fac_path, metadata = s.findPagePath(route_metadata, MODE_PARSING) - assert fac_path == expected_path + assert fac_path == slashfix(expected_path) assert metadata == expected_metadata
--- a/tests/test_sources_base.py Mon Mar 02 22:42:16 2015 -0800 +++ b/tests/test_sources_base.py Wed Mar 04 22:40:50 2015 -0800 @@ -3,6 +3,7 @@ from piecrust.app import PieCrust from piecrust.sources.pageref import PageRef, PageNotFoundError from .mockutil import mock_fs, mock_fs_scope +from .pathutil import slashfix @pytest.mark.parametrize('fs, expected_paths, expected_slugs', [ @@ -108,15 +109,16 @@ app = fs.getApp() r = PageRef(app, page_ref) - assert r.possible_paths == [os.path.join(fs.path('/kitchen'), p) - for p in expected_possible_paths] + assert r.possible_paths == slashfix( + [os.path.join(fs.path('/kitchen'), p) + for p in expected_possible_paths]) assert r.exists assert r.source_name == expected_source_name assert r.source == app.getSource(expected_source_name) assert r.rel_path == expected_rel_path - assert r.path == fs.path(os.path.join( - 'kitchen', expected_source_name, expected_rel_path)) + assert r.path == slashfix(fs.path(os.path.join( + 'kitchen', expected_source_name, expected_rel_path))) def test_page_ref_with_missing_source():