61 lines
2.7 KiB
Diff
61 lines
2.7 KiB
Diff
From 4f45a37a390d7c844dd9c9b58fff7259a77ffff9 Mon Sep 17 00:00:00 2001
|
|
From: Javi Merino <merino.jav@gmail.com>
|
|
Date: Sun, 31 Aug 2014 05:45:17 -0700
|
|
Subject: [PATCH] Fix should_output_info_for_multiple_files
|
|
|
|
Test should_output_info_for_multiple_files fails because the output is
|
|
not in the same order as the input. Add assert_equal_any_order() to
|
|
the OutputCollector, which sorts the expected and actual lines so that
|
|
the output matches even if the order in which they are shown in
|
|
trash-list is different.
|
|
---
|
|
integration_tests/describe_trash_list.py | 8 +++++---
|
|
integration_tests/output_collector.py | 8 ++++++++
|
|
2 files changed, 13 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/integration_tests/describe_trash_list.py b/integration_tests/describe_trash_list.py
|
|
index 6dd8d30..3489a22 100644
|
|
--- a/integration_tests/describe_trash_list.py
|
|
+++ b/integration_tests/describe_trash_list.py
|
|
@@ -73,9 +73,9 @@ def should_output_info_for_multiple_files(self):
|
|
|
|
self.user.run_trash_list()
|
|
|
|
- self.user.should_read_output( "2000-01-01 00:00:01 /file1\n"
|
|
- "2000-01-01 00:00:02 /file2\n"
|
|
- "2000-01-01 00:00:03 /file3\n")
|
|
+ self.user.should_read_output_any_order( "2000-01-01 00:00:01 /file1\n"
|
|
+ "2000-01-01 00:00:02 /file2\n"
|
|
+ "2000-01-01 00:00:03 /file3\n")
|
|
|
|
@istest
|
|
def should_output_unknown_dates_with_question_marks(self):
|
|
@@ -294,6 +294,8 @@ def error(self):
|
|
raise ValueError()
|
|
def should_read_output(self, expected_value):
|
|
self.stdout.assert_equal_to(expected_value)
|
|
+ def should_read_output_any_order(self, expected_value):
|
|
+ self.stdout.assert_equal_any_order(expected_value)
|
|
def should_read_error(self, expected_value):
|
|
self.stderr.assert_equal_to(expected_value)
|
|
def output(self):
|
|
diff --git a/integration_tests/output_collector.py b/integration_tests/output_collector.py
|
|
index 06dc002..7f3704f 100644
|
|
--- a/integration_tests/output_collector.py
|
|
+++ b/integration_tests/output_collector.py
|
|
@@ -9,6 +9,14 @@ def write(self,data):
|
|
self.stream.write(data)
|
|
def assert_equal_to(self, expected):
|
|
return self.should_be(expected)
|
|
+ def assert_equal_any_order(self, expected):
|
|
+ actual_sorted = sorted(self.stream.getvalue().splitlines(1))
|
|
+ actual = "".join(actual_sorted)
|
|
+
|
|
+ expected_sorted = sorted(expected.splitlines(1))
|
|
+ expected = "".join(expected_sorted)
|
|
+
|
|
+ assert_equals_with_unidiff(expected, actual)
|
|
def should_be(self, expected):
|
|
assert_equals_with_unidiff(expected, self.stream.getvalue())
|
|
def should_match(self, regex):
|