Mercurial > piecrust2
comparison tests/test_sources_base.py @ 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 | f130365568ff |
children | dd25bd3ce1f9 |
comparison
equal
deleted
inserted
replaced
285:6e9b5530306e | 286:a2d283d1033d |
---|---|
1 import os | 1 import os |
2 import pytest | 2 import pytest |
3 from piecrust.app import PieCrust | 3 from piecrust.app import PieCrust |
4 from piecrust.sources.pageref import PageRef, PageNotFoundError | 4 from piecrust.sources.pageref import PageRef, PageNotFoundError |
5 from .mockutil import mock_fs, mock_fs_scope | 5 from .mockutil import mock_fs, mock_fs_scope |
6 from .pathutil import slashfix | |
6 | 7 |
7 | 8 |
8 @pytest.mark.parametrize('fs, expected_paths, expected_slugs', [ | 9 @pytest.mark.parametrize('fs, expected_paths, expected_slugs', [ |
9 (mock_fs(), [], []), | 10 (mock_fs(), [], []), |
10 (mock_fs().withPage('test/foo.html'), | 11 (mock_fs().withPage('test/foo.html'), |
106 .withPage('bar/special.md')) | 107 .withPage('bar/special.md')) |
107 with mock_fs_scope(fs): | 108 with mock_fs_scope(fs): |
108 app = fs.getApp() | 109 app = fs.getApp() |
109 r = PageRef(app, page_ref) | 110 r = PageRef(app, page_ref) |
110 | 111 |
111 assert r.possible_paths == [os.path.join(fs.path('/kitchen'), p) | 112 assert r.possible_paths == slashfix( |
112 for p in expected_possible_paths] | 113 [os.path.join(fs.path('/kitchen'), p) |
114 for p in expected_possible_paths]) | |
113 | 115 |
114 assert r.exists | 116 assert r.exists |
115 assert r.source_name == expected_source_name | 117 assert r.source_name == expected_source_name |
116 assert r.source == app.getSource(expected_source_name) | 118 assert r.source == app.getSource(expected_source_name) |
117 assert r.rel_path == expected_rel_path | 119 assert r.rel_path == expected_rel_path |
118 assert r.path == fs.path(os.path.join( | 120 assert r.path == slashfix(fs.path(os.path.join( |
119 'kitchen', expected_source_name, expected_rel_path)) | 121 'kitchen', expected_source_name, expected_rel_path))) |
120 | 122 |
121 | 123 |
122 def test_page_ref_with_missing_source(): | 124 def test_page_ref_with_missing_source(): |
123 fs = mock_fs() | 125 fs = mock_fs() |
124 with mock_fs_scope(fs): | 126 with mock_fs_scope(fs): |