Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # coding: utf-8 | 1 # coding: utf-8 |
2 | 2 |
3 # This file is part of the Adblock Plus web scripts, | 3 # This file is part of the Adblock Plus web scripts, |
4 # Copyright (C) 2006-2014 Eyeo GmbH | 4 # Copyright (C) 2006-2014 Eyeo GmbH |
5 # | 5 # |
6 # Adblock Plus is free software: you can redistribute it and/or modify | 6 # Adblock Plus is free software: you can redistribute it and/or modify |
7 # it under the terms of the GNU General Public License version 3 as | 7 # it under the terms of the GNU General Public License version 3 as |
8 # published by the Free Software Foundation. | 8 # published by the Free Software Foundation. |
9 # | 9 # |
10 # Adblock Plus is distributed in the hope that it will be useful, | 10 # Adblock Plus is distributed in the hope that it will be useful, |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 "platform": "chromium", | 605 "platform": "chromium", |
606 "platformVersion": "28.0", | 606 "platformVersion": "28.0", |
607 "fullPlatform": "chromium 28.0", | 607 "fullPlatform": "chromium 28.0", |
608 "downloadInterval": "1 day(s)", | 608 "downloadInterval": "1 day(s)", |
609 "previousDownload": "2 day(s)", | 609 "previousDownload": "2 day(s)", |
610 "firstInDay": True, | 610 "firstInDay": True, |
611 } | 611 } |
612 ), | 612 ), |
613 ] | 613 ] |
614 for line, expected_record in tests: | 614 for line, expected_record in tests: |
615 result = logprocessor.parse_record(line, set(), FakeGeo(), FakeGeo()) | 615 self.assertEqual(logprocessor.parse_record(line, set(), FakeGeo(), FakeGeo ()), expected_record, "Parsing log line '%s'" % line) |
616 # assertEqual() treats identical Unicode and non-Unicode strings as | |
617 # different, make sure that all our strings are non-Unicode. | |
Sebastian Noack
2014/09/18 15:50:04
Why don't you just use unicode literals above?
Wladimir Palant
2014/09/18 18:42:50
Because I don't know which one will use Unicode -
Sebastian Noack
2014/09/19 09:48:42
According to my tests it doesn't. All strings in t
Wladimir Palant
2014/09/22 10:39:05
For some reason I cannot reproduce it any longer,
| |
618 if result: | |
619 for key, value in result.iteritems(): | |
620 if isinstance(value, unicode): | |
621 result[key] = str(value) | |
622 self.assertEqual(result, expected_record, "Parsing log line '%s'" % line) | |
623 | 616 |
624 def test_record_adding(self): | 617 def test_record_adding(self): |
625 tests = [ | 618 tests = [ |
626 ( | 619 ( |
627 {"size": 200}, | 620 {"size": 200}, |
628 {}, | 621 {}, |
629 (), | 622 (), |
630 {"hits": 1, "bandwidth": 200}, | 623 {"hits": 1, "bandwidth": 200}, |
631 ), | 624 ), |
632 ( | 625 ( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 "addonName": {"bar": {"hits": 1, "bandwidth": 200}} | 666 "addonName": {"bar": {"hits": 1, "bandwidth": 200}} |
674 }, | 667 }, |
675 ), | 668 ), |
676 ] | 669 ] |
677 for info, section, ignored_fields, expected_result in tests: | 670 for info, section, ignored_fields, expected_result in tests: |
678 logprocessor.add_record(info, section, ignored_fields) | 671 logprocessor.add_record(info, section, ignored_fields) |
679 self.assertEqual(section, expected_result) | 672 self.assertEqual(section, expected_result) |
680 | 673 |
681 if __name__ == '__main__': | 674 if __name__ == '__main__': |
682 unittest.main() | 675 unittest.main() |
LEFT | RIGHT |