diff options
| author | Tom Christie | 2011-04-27 18:29:12 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-04-27 18:29:12 +0100 |
| commit | 1e1c4f85fc0d1a9ea0593b6906b6a09ec549c972 (patch) | |
| tree | 7dd74114ad7be23847c6e49dd64cf4047127ee33 /examples/pygments_api | |
| parent | cc004dbca19882d301516494f0b73af940aeb6bb (diff) | |
| parent | fb805bbb7ca80808258520219330cc5fb3bc0517 (diff) | |
| download | django-rest-framework-1e1c4f85fc0d1a9ea0593b6906b6a09ec549c972.tar.bz2 | |
Pulling marko's test fixes
Diffstat (limited to 'examples/pygments_api')
| -rw-r--r-- | examples/pygments_api/tests.py | 4 | ||||
| -rw-r--r-- | examples/pygments_api/views.py | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/examples/pygments_api/tests.py b/examples/pygments_api/tests.py index 262f02b3..766defc3 100644 --- a/examples/pygments_api/tests.py +++ b/examples/pygments_api/tests.py @@ -37,12 +37,14 @@ class TestPygmentsExample(TestCase): def test_snippets_datetime_sorted(self):
'''Pygments examples should be datetime sorted'''
locations = []
- for snippet in 'abcdefghijk':
+ for snippet in 'abcdefghij': # String length must not exceed views.MAX_FILES, otherwise test fails
form_data = {'code': '%s' % snippet, 'style':'friendly', 'lexer':'python'}
request = self.factory.post('/pygments', data=form_data)
view = views.PygmentsRoot.as_view()
response = view(request)
locations.append(response.items()[2][1])
+ import time
+ time.sleep(.1)
request = self.factory.get('/pygments')
view = views.PygmentsRoot.as_view()
response = view(request)
diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py index f1a89702..4e6d1230 100644 --- a/examples/pygments_api/views.py +++ b/examples/pygments_api/views.py @@ -25,7 +25,7 @@ def list_dir_sorted_by_ctime(dir): """Return a list of files sorted by creation time""" filepaths = [os.path.join(dir, file) for file in os.listdir(dir) if not file.startswith('.')] return [item[0] for item in sorted([(path, os.path.getctime(path)) for path in filepaths], - key=operator.itemgetter(1), reverse=True)] + key=operator.itemgetter(1), reverse=False)] def remove_oldest_files(dir, max_files): """Remove the oldest files in a directory 'dir', leaving at most 'max_files' remaining. We use this to limit the number of resources in the sandbox.""" |
