Ticket #1099: test-no-stdout-encoding.dpatch

File test-no-stdout-encoding.dpatch, 5.6 KB (added by davidsarah, at 2010-07-17T05:14:29Z)

stringutils: add test for when sys.stdout has no encoding attribute (fixes #1099).

Line 
1Sat Jul 17 05:58:16 GMT Daylight Time 2010  david-sarah@jacaranda.org
2  * stringutils: add test for when sys.stdout has no encoding attribute (fixes #1099).
3
4New patches:
5
6[stringutils: add test for when sys.stdout has no encoding attribute (fixes #1099).
7david-sarah@jacaranda.org**20100717045816
8 Ignore-this: f28dce6940e909f12f354086d17db54f
9] {
10hunk ./src/allmydata/test/test_stringutils.py 56
11 
12 from twisted.trial import unittest
13 from mock import patch
14-import sys
15+import sys, locale
16 
17 from allmydata.test.common_util import ReallyEqualMixin
18 from allmydata.util.stringutils import argv_to_unicode, unicode_to_url, \
19hunk ./src/allmydata/test/test_stringutils.py 87
20         mock_stdout.encoding = 'nonexistent_encoding'
21         self.failUnlessRaises(AssertionError, _reload)
22 
23-        # TODO: mock_stdout.encoding = None
24+    @patch('locale.getpreferredencoding')
25+    def test_get_output_encoding_not_from_stdout(self, mock_locale_getpreferredencoding):
26+        locale  # hush pyflakes
27+        mock_locale_getpreferredencoding.return_value = 'koi8-r'
28+
29+        class DummyStdout:
30+            pass
31+        old_stdout = sys.stdout
32+        sys.stdout = DummyStdout()
33+        try:
34+            _reload()
35+            self.failUnlessReallyEqual(get_output_encoding(), 'koi8-r')
36+
37+            sys.stdout.encoding = None
38+            _reload()
39+            self.failUnlessReallyEqual(get_output_encoding(), 'koi8-r')
40+
41+            mock_locale_getpreferredencoding.return_value = None
42+            _reload()
43+            self.failUnlessReallyEqual(get_output_encoding(), 'utf-8')
44+        finally:
45+            sys.stdout = old_stdout
46 
47     @patch('sys.stdout')
48     def test_argv_to_unicode(self, mock):
49}
50
51Context:
52
53[docs: CREDITS and NEWS
54zooko@zooko.com**20100714060150
55 Ignore-this: dc83e612f77d69e50ee975f07f6b16fe
56] 
57[CREDITS: more creds for Kevan, plus utf-8 BOM
58zooko@zooko.com**20100619045503
59 Ignore-this: 72d02bdd7a0f324f1cee8cd399c7c6de
60] 
61[cli.py: make command descriptions consistently end with a full stop.
62david-sarah@jacaranda.org**20100714014538
63 Ignore-this: 9ee7fa29ca2d1631db4049c2a389a97a
64] 
65[SFTP: address some of the comments in zooko's review (#1106).
66david-sarah@jacaranda.org**20100712025537
67 Ignore-this: c3921638a2d4f1de2a776ae78e4dc37e
68] 
69[docs/logging.txt: note that setting flogging vars might affect tests with race conditions.
70david-sarah@jacaranda.org**20100712050721
71 Ignore-this: fc1609d215fcd5561a57fd1226206f27
72] 
73[test_storage.py: potential fix for failures when logging is enabled.
74david-sarah@jacaranda.org**19700713040546
75 Ignore-this: 5815693a0df3e64c52c3c6b7be2846c7
76] 
77[upcase_since_on_welcome
78terrellrussell@gmail.com**20100708193903] 
79[server_version_on_welcome_page.dpatch.txt
80freestorm77@gmail.com**20100605191721
81 Ignore-this: b450c76dc875f5ac8cca229a666cbd0a
82 
83 
84 - The storage server version is 0 for all storage nodes in the Welcome Page
85 
86 
87] 
88[NEWS: add NEWS snippets about two recent patches
89zooko@zooko.com**20100708162058
90 Ignore-this: 6c9da6a0ad7351a960bdd60f81532899
91] 
92[directory_html_top_banner.dpatch
93freestorm77@gmail.com**20100622205301
94 Ignore-this: 1d770d975e0c414c996564774f049bca
95 
96 The div tag with the link "Return to Welcome page" on the directory.xhtml page is not correct
97 
98] 
99[tahoe_css_toolbar.dpatch
100freestorm77@gmail.com**20100622210046
101 Ignore-this: 5b3ebb2e0f52bbba718a932f80c246c0
102 
103 CSS modification to be correctly diplayed with Internet Explorer 8
104 
105 The links on the top of page directory.xhtml are not diplayed in the same line as display with Firefox.
106 
107] 
108[runnin_test_tahoe_css.dpatch
109freestorm77@gmail.com**20100622214714
110 Ignore-this: e0db73d68740aad09a7b9ae60a08c05c
111 
112 Runnin test for changes in tahoe.css file
113 
114] 
115[runnin_test_directory_xhtml.dpatch
116freestorm77@gmail.com**20100622201403
117 Ignore-this: f8962463fce50b9466405cb59fe11d43
118 
119 Runnin test for diretory.xhtml top banner
120 
121] 
122[stringutils.py: tolerate sys.stdout having no 'encoding' attribute.
123david-sarah@jacaranda.org**20100626040817
124 Ignore-this: f42cad81cef645ee38ac1df4660cc850
125] 
126[quickstart.html: python 2.5 -> 2.6 as recommended version
127david-sarah@jacaranda.org**20100705175858
128 Ignore-this: bc3a14645ea1d5435002966ae903199f
129] 
130[SFTP: don't call .stopProducing on the producer registered with OverwriteableFileConsumer (which breaks with warner's new downloader).
131david-sarah@jacaranda.org**20100628231926
132 Ignore-this: 131b7a5787bc85a9a356b5740d9d996f
133] 
134[docs/how_to_make_a_tahoe-lafs_release.txt: trivial correction, install.html should now be quickstart.html.
135david-sarah@jacaranda.org**20100625223929
136 Ignore-this: 99a5459cac51bd867cc11ad06927ff30
137] 
138[setup: in the Makefile, refuse to upload tarballs unless someone has passed the environment variable "BB_BRANCH" with value "trunk"
139zooko@zooko.com**20100619034928
140 Ignore-this: 276ddf9b6ad7ec79e27474862e0f7d6
141] 
142[trivial: tiny update to in-line comment
143zooko@zooko.com**20100614045715
144 Ignore-this: 10851b0ed2abfed542c97749e5d280bc
145 (I'm actually committing this patch as a test of the new eager-annotation-computation of trac-darcs.)
146] 
147[docs: about.html link to home page early on, and be decentralized storage instead of cloud storage this time around
148zooko@zooko.com**20100619065318
149 Ignore-this: dc6db03f696e5b6d2848699e754d8053
150] 
151[docs: update about.html, especially to have a non-broken link to quickstart.html, and also to comment out the broken links to "for Paranoids" and "for Corporates"
152zooko@zooko.com**20100619065124
153 Ignore-this: e292c7f51c337a84ebfeb366fbd24d6c
154] 
155[TAG allmydata-tahoe-1.7.0
156zooko@zooko.com**20100619052631
157 Ignore-this: d21e27afe6d85e2e3ba6a3292ba2be1
158] 
159Patch bundle hash:
1601e7e033aed6023cb7e6e2d10160537cee5fa611b