Skip to content

Commit

Permalink
Fix broken tests and have travis run parallel builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnephin committed Jan 20, 2015
1 parent 0c62a9e commit 7a34fee
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
14 changes: 11 additions & 3 deletions .travis.yml
@@ -1,6 +1,14 @@
language: python
env:
- TOX_ENV=py26
- TOX_ENV=py27
- TOX_ENV=py33
- TOX_ENV=py34
- TOX_ENV=pypy
- TOX_ENV=docs
- TOX_ENV=coverage

install:
- pip install tox
- pip install coveralls
script: tox
- pip install --use-mirrors tox coveralls
script: tox -e $TOX_ENV
after_success: coveralls
2 changes: 1 addition & 1 deletion Makefile
@@ -1,5 +1,5 @@

.PHONY: clean docs testi upload
.PHONY: clean docs test upload


clean:
Expand Down
4 changes: 2 additions & 2 deletions staticconf/config.py
Expand Up @@ -435,10 +435,10 @@ def __init__(self, filenames):
def get_hashes(self):
def build_hash(filename):
hasher = hashlib.md5()
with open(filename) as fh:
with open(filename, 'rb') as fh:
hasher.update(fh.read())
return hasher.digest()
return map(build_hash, self.filenames)
return [build_hash(filename) for filename in self.filenames]

def has_changed(self):
last_hashes, self.hashes = self.hashes, self.get_hashes()
Expand Down
11 changes: 6 additions & 5 deletions tests/config_test.py
Expand Up @@ -354,7 +354,8 @@ def test_should_check(self):
assert self.watcher.should_check

def test_file_modified_not_modified(self):
self.watcher.last_max_mtime = self.mock_path.getmtime.return_value = 222
self.watcher.comparators[1].last_max_mtime = mtime = 222
self.mock_path.getmtime.return_value = mtime
self.mock_time.time.return_value = 123456
assert not self.watcher.file_modified()
assert_equal(self.watcher.last_check, self.mock_time.time.return_value)
Expand All @@ -367,8 +368,8 @@ def test_file_modified(self):
assert_equal(self.watcher.last_check, self.mock_time.time.return_value)

def test_file_modified_moved(self):
self.mock_path.getmtime.return_value = 123456
self.watcher.last_max_mtime = 123456
self.mock_path.getmtime.return_value = mtime = 123456
self.watcher.comparators[1].last_max_mtime = mtime
assert not self.watcher.file_modified()
self.mock_stat.return_value.st_ino = 3
assert self.watcher.file_modified()
Expand Down Expand Up @@ -399,7 +400,7 @@ class TestMD5Comparator(object):

@pytest.yield_fixture()
def comparator(self):
self.original_contents = "abcdefghijkabcd"
self.original_contents = b"abcdefghijkabcd"
with tempfile.NamedTemporaryFile() as self.file:
self.write_contents(self.original_contents)
yield config.MD5Comparator([self.file.name])
Expand All @@ -416,7 +417,7 @@ def test_has_changed_no_changes(self, comparator):

def test_has_changed_with_changes(self, comparator):
assert not comparator.has_changed()
self.write_contents("this is the new content")
self.write_contents(b"this is the new content")
assert comparator.has_changed()


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py26,py27,py33,py34,pypy,coverage
envlist = py26,py27,py33,py34,pypy,docs,coverage

[testenv]
deps =
Expand Down

0 comments on commit 7a34fee

Please sign in to comment.