Skip to content

Commit 951acac

Browse files
committed
Merge branch 'master' of github.com:bpython/bpython
Conflicts: .travis.yml
2 parents 97c2b06 + f977d81 commit 951acac

File tree

4 files changed

+44
-34
lines changed

4 files changed

+44
-34
lines changed

bpython/test/test_crashers.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
import sys
66
import termios
77
import textwrap
8-
import unittest
98

109
try:
11-
from unittest import skip
10+
import unittest2 as unittest
1211
except ImportError:
13-
def skip(f):
14-
return lambda self: None
12+
import unittest
1513

1614
try:
1715
from twisted.internet import reactor
@@ -103,14 +101,13 @@ def spam(a, (b, c)):
103101
return self.run_bpython(input).addCallback(self.check_no_traceback)
104102

105103
def check_no_traceback(self, data):
106-
tb = data[data.find("Traceback"):]
107-
self.assertTrue("Traceback" not in data, tb)
104+
self.assertNotIn("Traceback", data)
108105

109106
if reactor is not None:
110107
class CursesCrashersTest(TrialTestCase, CrashersTest):
111108
backend = "cli"
112109

113-
@skip("take 6 seconds, and Simon says we can skip them")
110+
@unittest.skip("take 6 seconds, and Simon says we can skip them")
114111
class UrwidCrashersTest(TrialTestCase, CrashersTest):
115112
backend = "urwid"
116113

bpython/test/test_manual_readline.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
try:
2+
import unittest2 as unittest
3+
except ImportError:
4+
import unittest
5+
16
from bpython.curtsiesfrontend.manual_readline import *
2-
import unittest
7+
38

49
class TestManualReadline(unittest.TestCase):
510
def setUp(self):
@@ -222,7 +227,7 @@ def setUp(self):
222227
def test_seq(self):
223228
f = lambda cursor_offset, line: ('hi', 2)
224229
self.edits.add('a', f)
225-
self.assertTrue('a' in self.edits)
230+
self.assertIn('a', self.edits)
226231
self.assertEqual(self.edits['a'], f)
227232
self.assertEqual(self.edits.call('a', cursor_offset=3, line='hello'),
228233
('hi', 2))
@@ -245,12 +250,12 @@ def test_config(self):
245250
f = lambda cursor_offset, line: ('hi', 2)
246251
g = lambda cursor_offset, line: ('hey', 3)
247252
self.edits.add_config_attr('att', f)
248-
self.assertFalse('att' in self.edits)
253+
self.assertNotIn('att', self.edits)
249254
class config: att = 'c'
250255
key_dispatch = {'c': 'c'}
251256
configured_edits = self.edits.mapping_with_config(config, key_dispatch)
252257
self.assertTrue(configured_edits.__contains__, 'c')
253-
self.assertFalse('c' in self.edits)
258+
self.assertNotIn('c', self.edits)
254259
self.assertRaises(NotImplementedError,
255260
configured_edits.add_config_attr, 'att2', g)
256261
self.assertRaises(NotImplementedError,

bpython/test/test_repl.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
import os
44
import socket
55
import sys
6-
import unittest
76

87
from mock import Mock, MagicMock
98

109
try:
11-
from unittest import skip
10+
import unittest2 as unittest
1211
except ImportError:
13-
def skip(f):
14-
return lambda self: None
12+
import unittest
1513

1614
py3 = (sys.version_info[0] == 3)
1715

@@ -101,7 +99,7 @@ def test_append(self):
10199

102100
self.assertEqual(self.history.back(), 'print "foo\n"')
103101

104-
@skip("I don't understand this test")
102+
@unittest.skip("I don't understand this test")
105103
def test_enter(self):
106104
self.history.enter('#lastnumber!')
107105

@@ -278,7 +276,7 @@ def assert_get_source_error_for_current_function(self, func, msg):
278276
def test_current_function(self):
279277
self.set_input_line('INPUTLINE')
280278
self.repl.current_func = collections.MutableSet.add
281-
self.assertTrue("Add an element." in self.repl.get_source_of_current_name())
279+
self.assertIn("Add an element.", self.repl.get_source_of_current_name())
282280

283281
self.assert_get_source_error_for_current_function(
284282
collections.defaultdict.copy, "No source code found for INPUTLINE")
@@ -295,7 +293,7 @@ def test_current_function(self):
295293
def test_current_line(self):
296294
self.repl.interp.locals['a'] = socket.socket
297295
self.set_input_line('a')
298-
self.assertTrue('dup(self)' in self.repl.get_source_of_current_name())
296+
self.assertIn('dup(self)', self.repl.get_source_of_current_name())
299297

300298
#TODO add tests for various failures without using current function
301299

@@ -334,7 +332,7 @@ def test_simple_global_complete(self):
334332
self.assertEqual(self.repl.matches_iter.matches,
335333
['def', 'del', 'delattr(', 'dict(', 'dir(', 'divmod('])
336334

337-
@skip("disabled while non-simple completion is disabled")
335+
@unittest.skip("disabled while non-simple completion is disabled")
338336
def test_substring_global_complete(self):
339337
self.repl = FakeRepl({'autocomplete_mode': autocomplete.SUBSTRING})
340338
self.setInputLine("time")
@@ -344,7 +342,7 @@ def test_substring_global_complete(self):
344342
self.assertEqual(self.repl.completer.matches,
345343
['RuntimeError(', 'RuntimeWarning('])
346344

347-
@skip("disabled while non-simple completion is disabled")
345+
@unittest.skip("disabled while non-simple completion is disabled")
348346
def test_fuzzy_global_complete(self):
349347
self.repl = FakeRepl({'autocomplete_mode': autocomplete.FUZZY})
350348
self.setInputLine("doc")
@@ -368,7 +366,7 @@ def test_simple_attribute_complete(self):
368366
self.assertEqual(self.repl.matches_iter.matches,
369367
['Foo.bar'])
370368

371-
@skip("disabled while non-simple completion is disabled")
369+
@unittest.skip("disabled while non-simple completion is disabled")
372370
def test_substring_attribute_complete(self):
373371
self.repl = FakeRepl({'autocomplete_mode': autocomplete.SUBSTRING})
374372
self.setInputLine("Foo.az")
@@ -382,7 +380,7 @@ def test_substring_attribute_complete(self):
382380
self.assertEqual(self.repl.completer.matches,
383381
['Foo.baz'])
384382

385-
@skip("disabled while non-simple completion is disabled")
383+
@unittest.skip("disabled while non-simple completion is disabled")
386384
def test_fuzzy_attribute_complete(self):
387385
self.repl = FakeRepl({'autocomplete_mode': autocomplete.FUZZY})
388386
self.setInputLine("Foo.br")
@@ -412,7 +410,7 @@ def test_file_should_not_appear_in_complete(self):
412410
self.setInputLine("_")
413411
self.assertTrue(self.repl.complete())
414412
self.assertTrue(hasattr(self.repl.matches_iter,'matches'))
415-
self.assertTrue('__file__' not in self.repl.matches_iter.matches)
413+
self.assertNotIn('__file__', self.repl.matches_iter.matches)
416414

417415

418416
class TestCliRepl(unittest.TestCase):
@@ -465,7 +463,7 @@ def test_simple_tab_complete(self):
465463
self.repl.complete.assert_called_with(tab=True)
466464
self.assertEqual(self.repl.s, "foobar")
467465

468-
@skip("disabled while non-simple completion is disabled")
466+
@unittest.skip("disabled while non-simple completion is disabled")
469467
def test_substring_tab_complete(self):
470468
self.repl.s = "bar"
471469
self.repl.config.autocomplete_mode = autocomplete.FUZZY
@@ -474,7 +472,7 @@ def test_substring_tab_complete(self):
474472
self.repl.tab()
475473
self.assertEqual(self.repl.s, "foofoobar")
476474

477-
@skip("disabled while non-simple completion is disabled")
475+
@unittest.skip("disabled while non-simple completion is disabled")
478476
def test_fuzzy_tab_complete(self):
479477
self.repl.s = "br"
480478
self.repl.config.autocomplete_mode = autocomplete.FUZZY
@@ -509,7 +507,7 @@ def test_back_parameter(self):
509507
self.assertTrue(self.repl.s, "previtem")
510508

511509
# Attribute Tests
512-
@skip("disabled while non-simple completion is disabled")
510+
@unittest.skip("disabled while non-simple completion is disabled")
513511
def test_fuzzy_attribute_tab_complete(self):
514512
"""Test fuzzy attribute with no text"""
515513
self.repl.s = "Foo."
@@ -518,7 +516,7 @@ def test_fuzzy_attribute_tab_complete(self):
518516
self.repl.tab()
519517
self.assertEqual(self.repl.s, "Foo.foobar")
520518

521-
@skip("disabled while non-simple completion is disabled")
519+
@unittest.skip("disabled while non-simple completion is disabled")
522520
def test_fuzzy_attribute_tab_complete2(self):
523521
"""Test fuzzy attribute with some text"""
524522
self.repl.s = "Foo.br"
@@ -538,14 +536,14 @@ def test_simple_expand(self):
538536
self.repl.tab()
539537
self.assertEqual(self.repl.s, "foo")
540538

541-
@skip("disabled while non-simple completion is disabled")
539+
@unittest.skip("disabled while non-simple completion is disabled")
542540
def test_substring_expand_forward(self):
543541
self.repl.config.autocomplete_mode = autocomplete.SUBSTRING
544542
self.repl.s = "ba"
545543
self.repl.tab()
546544
self.assertEqual(self.repl.s, "bar")
547545

548-
@skip("disabled while non-simple completion is disabled")
546+
@unittest.skip("disabled while non-simple completion is disabled")
549547
def test_fuzzy_expand(self):
550548
pass
551549

setup.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ def initialize_options(self):
135135
]
136136
data_files.extend(man_pages)
137137

138+
install_requires = [
139+
'pygments',
140+
'requests'
141+
]
142+
138143
extras_require = {
139144
'urwid' : ['urwid']
140145
}
@@ -161,6 +166,14 @@ def initialize_options(self):
161166
if not using_setuptools:
162167
scripts.append('data/bpython-curtsies')
163168

169+
if sys.version_info[0] == 2 and sys.platform == "darwin":
170+
# need PyOpenSSL for SNI support (only 2.X and on Darwin)
171+
# list of packages taken from
172+
# https://github.com/kennethreitz/requests/blob/master/requests/packages/urllib3/contrib/pyopenssl.py
173+
install_requires.append('PyOpenSSL')
174+
install_requires.append('ndg-httpsclient')
175+
install_requires.append('pyasn1')
176+
164177
# translations
165178
mo_files = list()
166179
for language in os.listdir(translations_dir):
@@ -178,12 +191,9 @@ def initialize_options(self):
178191
url = "http://www.bpython-interpreter.org/",
179192
long_description = """bpython is a fancy interface to the Python
180193
interpreter for Unix-like operating systems.""",
181-
install_requires = [
182-
'pygments',
183-
'requests'
184-
],
194+
install_requires = install_requires,
185195
extras_require = extras_require,
186-
tests_require = ['mock'],
196+
tests_require = ['mock', 'unittest2'],
187197
packages = packages,
188198
data_files = data_files,
189199
package_data = {

0 commit comments

Comments
 (0)