# HG changeset patch # User Ludovic Chabant # Date 1425537650 28800 # Node ID a2d283d1033de473d2ce512a45dd5302ad95ac3a # Parent 6e9b5530306e863d5fbf75170f6fea1d2f84af1c tests: Fixes for running on Windows. Mostly about those damn backslashes, as usual. diff -r 6e9b5530306e -r a2d283d1033d piecrust/baking/single.py --- 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. diff -r 6e9b5530306e -r a2d283d1033d piecrust/sources/autoconfig.py --- 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\d+)_') + re_pattern = re.compile(r'(^|[/\\])(?P\d+)_') def __init__(self, app, name, config): config['capture_mode'] = 'path' diff -r 6e9b5530306e -r a2d283d1033d tests/pathutil.py --- /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 + diff -r 6e9b5530306e -r a2d283d1033d tests/test_baking_baker.py --- 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) diff -r 6e9b5530306e -r a2d283d1033d tests/test_sources_autoconfig.py --- 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 diff -r 6e9b5530306e -r a2d283d1033d tests/test_sources_base.py --- 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():