Comments (7)
The Bob test suite uses unicode_literals
to make sure that all strings are interpreted as unicode.
from python.
Have you run into some actual problems with the test suite? Unexpected test result?
Otherwise I'll close this.
from python.
There was a discussion in one of the submissions where they had to use str.decode()
with str.isupper()
and this was the only way I could figure out to reproduce the behavior.
from python.
It would be super helpful if you could track down that submission or reproduce it!
Otherwise, maybe @kytrinyx can help us find it?
from python.
I'm closing this for now but I'd be happy to discuss (and try to fix) this if the bug can actually be reproduced in a supported version of Python (2.7, 3.3, 3.4).
from python.
I ran into this issue while trying to demonstrate Exercism to a student new to programming. It was an unfortunate hurdle to encounter so early in the process.
There is certainly value in understanding the intricacies of Python unicode handling (and differences between 2 and 3), but I don't think Exercism's hello-world
exercise is the right place to be confronted with those things.
$ python2.7 hello_world_test.py
.E.
======================================================================
ERROR: test_hello_with_umlaut_name (__main__.BobTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "hello_world_test.py", line 26, in test_hello_with_umlaut_name
hello_world.hello('Jürgen')
File "/Users/english/exercism/python/hello-world/hello_world.py", line 8, in hello
return "Hello, {}!".format(name)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal
not in range(128)
----------------------------------------------------------------------
Ran 3 tests in 0.000s
FAILED (errors=1)
$ python3 hello_world_test.py
...
----------------------------------------------------------------------
Ran 3 tests in 0.000s
OK
$
For hello_world.py
:
def hello(name=''):
if name != '':
return "Hello, {}!".format(name)
else:
return 'Hello, World!'
(Very nearly the current example.py, so the results should be the same)
And hello_world_test.py
:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import unittest
import hello_world
class BobTests(unittest.TestCase):
def test_hello_without_name(self):
self.assertEqual(
'Hello, World!',
hello_world.hello()
)
def test_hello_with_name(self):
self.assertEqual(
'Hello, Jane!',
hello_world.hello('Jane')
)
def test_hello_with_umlaut_name(self):
self.assertEqual(
'Hello, Jürgen!',
hello_world.hello('Jürgen')
)
if __name__ == '__main__':
unittest.main()
Note that 2.7.x is still the default Python installed on many platforms, including macOS:
$ /usr/bin/python --version
Python 2.7.10
from python.
@englishm I've opened a new issue in the Python track about this: #1353
from python.
Related Issues (20)
- Plane Tickets yield expression link not working correctly in the ui HOT 1
- Clarify that the root is a natural number in square-root documentation HOT 2
- Instructions for python flatten: change null into None HOT 2
- Add additional test case to 'Matching Brackets' HOT 2
- Forth Exercise HOT 3
- [Little Sister’s Essay] A typo in the exercise introduction HOT 3
- [Card Games] `approx_average_is_average` docstring summary needs improvement HOT 3
- [Inventory Management] `list_inventory` docstring summary needs improvement HOT 3
- [Mecha Munch Management]: Typos in hints for task #5 (`send_to_store`) HOT 2
- Include pylintrc and pytest.ini files for each exercise HOT 1
- Chandan HOT 1
- Money maker HOT 1
- Wrong param type HOT 1
- Improve Triangles testing HOT 1
- exercise pov source - 4clojure website is defunct HOT 1
- There are some grammatical errors in the instructions and introduction files. It will be great for the new comers to understand things easily HOT 1
- How come the "Wordy" exercise labeled as "Easy"? HOT 1
- Question / contributing. HOT 1
- test HOT 1
- Hai HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python.