From 31bfdbeb1a5911e4c313b6742dfb6cb70ee13a5c Mon Sep 17 00:00:00 2001 From: markotibold Date: Wed, 27 Apr 2011 14:28:48 +0200 Subject: reverse on a a sorted list which was laerady reversed is rather pointless :) --- examples/pygments_api/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples/pygments_api') diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py index 6fb9217a..377761b1 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.""" -- cgit v1.2.3 From 391560e69c5e37edac2e3c470253e7dce3c62511 Mon Sep 17 00:00:00 2001 From: markotibold Date: Wed, 27 Apr 2011 14:29:59 +0200 Subject: The test was bad. It expected 11 snippets while the view made sure (as designed) that there would not be more than 10 snippets stored on disk. --- examples/pygments_api/tests.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples/pygments_api') diff --git a/examples/pygments_api/tests.py b/examples/pygments_api/tests.py index b4b01e8d..3bdc2ec5 100644 --- a/examples/pygments_api/tests.py +++ b/examples/pygments_api/tests.py @@ -28,12 +28,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) -- cgit v1.2.3