Skip to content

Commit 76e2948

Browse files
committed
Fix tests
1 parent fd3c089 commit 76e2948

File tree

5 files changed

+10
-19
lines changed

5 files changed

+10
-19
lines changed

test/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import re
23
import shutil
34
import subprocess
45
import tempfile
@@ -8,7 +9,7 @@
89

910
__all__ = ['this_dir', 'test_data_dir', 'test_stage_dir', 'stage_dir', 'pushd',
1011
'copytree', 'check_call_silent', 'check_output', 'git_config',
11-
'git_init', 'commit_files', 'assertDirectory']
12+
'git_init', 'commit_files', 'match_redir', 'assertDirectory']
1213

1314
this_dir = os.path.abspath(os.path.dirname(__file__))
1415
test_data_dir = os.path.join(this_dir, 'data')
@@ -115,6 +116,10 @@ def relpaths(paths, base):
115116
return [os.path.relpath(i, base) for i in paths]
116117

117118

119+
def match_redir(url):
120+
return r'window\.location\.replace\("{}"'.format(re.escape(url))
121+
122+
118123
def assertDirectory(path, contents, include_hidden=False, allow_extra=False):
119124
path = os.path.normpath(path)
120125
actual = set(os.path.normpath(os.path.join(base, f))

test/integration/test_alias.py

-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import os
2-
import re
32
import unittest
43

54
from . import assertPopen, assertOutput
65
from .. import *
76
from mike import git_utils, versions
87

98

10-
def match_redir(url):
11-
return r'window\.location\.replace\("{}"\)'.format(re.escape(url))
12-
13-
149
class AliasTestCase(unittest.TestCase):
1510
def _deploy(self, branch=None, versions=['1.0'], prefix=''):
1611
extra_args = ['-b', branch] if branch else []

test/integration/test_deploy.py

-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import os
2-
import re
32
import unittest
43

54
from . import assertPopen, assertOutput
65
from .. import *
76
from mike import git_utils, versions
87

98

10-
def match_redir(url):
11-
return r'window\.location\.replace\("{}"\)'.format(re.escape(url))
12-
13-
149
class DeployTestCase(unittest.TestCase):
1510
def _test_deploy(self, expected_message=None,
1611
expected_versions=[versions.VersionInfo('1.0')],

test/integration/test_set_default.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def _deploy(self, branch=None, versions=['1.0'], prefix=''):
1414
for i in versions:
1515
assertPopen(['mike', 'deploy', i] + extra_args)
1616

17-
def _test_default(self, expr=r'window\.location\.replace\("1\.0/"\)',
18-
expected_message=None, directory='.'):
17+
def _test_default(self, expr=match_redir('1.0/'), expected_message=None,
18+
directory='.'):
1919
message = assertPopen(['git', 'log', '-1', '--pretty=%B']).rstrip()
2020
if expected_message:
2121
self.assertEqual(message, expected_message)

test/unit/test_commands.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
from mike import commands, git_utils, versions
1111

1212

13-
def match_redir(url):
14-
return r'window\.location\.replace\("{}"\)'.format(re.escape(url))
15-
16-
1713
class MockConfig:
1814
def __init__(self, site_dir, remote_name='origin',
1915
remote_branch='gh-pages', use_directory_urls=True):
@@ -539,8 +535,8 @@ def _deploy(self, branch='gh-pages', prefix=''):
539535
with commands.deploy(self.cfg, '1.0', branch=branch, prefix=prefix):
540536
pass
541537

542-
def _test_default(self, expr=r'window\.location\.replace\("1\.0/"\)',
543-
expected_message=None, directory='.'):
538+
def _test_default(self, expr=match_redir('1.0/'), expected_message=None,
539+
directory='.'):
544540
message = check_output(['git', 'log', '-1', '--pretty=%B']).rstrip()
545541
if expected_message:
546542
self.assertEqual(message, expected_message)

0 commit comments

Comments
 (0)