Merge lp:~diegosarmentero/ubuntuone-dev-tools/temp-bytes into lp:ubuntuone-dev-tools

Proposed by Diego Sarmentero
Status: Merged
Approved by: Diego Sarmentero
Approved revision: 103
Merged at revision: 97
Proposed branch: lp:~diegosarmentero/ubuntuone-dev-tools/temp-bytes
Merge into: lp:ubuntuone-dev-tools
Diff against target: 63 lines (+41/-1)
3 files modified
ubuntuone/devtools/runners/__init__.py (+1/-1)
ubuntuone/devtools/runners/tests/__init__.py (+1/-0)
ubuntuone/devtools/runners/tests/test_base.py (+39/-0)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-dev-tools/temp-bytes
Reviewer Review Type Date Requested Status
dobey (community) Approve
Review via email: mp+126973@code.launchpad.net

Commit message

- Making temp-directory to be bytes to avoid encoding problems in tests.

To post a comment you must log in.
Revision history for this message
dobey (dobey) wrote :

Can you please file a bug for this (temp directory being unicode when it should be bytes), and add a regression test so that we can ensure it doesn't pop up again? Thanks.

review: Needs Fixing
98. By Diego Sarmentero

Adding regression test

99. By Diego Sarmentero

fixing docstring

100. By Diego Sarmentero

fixing import order

Revision history for this message
dobey (dobey) wrote :

62 + def test_check_temp_directory_is_bytes(self):
63 + """Check that the temp-directory value is bytes."""
64 + base_options = runners.BaseTestOptions()
65 + self.assertIsInstance(base_options.optParameters[5][2], str)

Instead of poking at this directly, I think it's probably better to perhaps check that self.tempdir.decode('utf-8') succeeds. If the parameters list changes in the future, your test will break, even when it shouldn't, as it depends on the order of the parameters. Also, I think your test will fail on python3, as the instance of that parameter should be 'bytes' instead of 'str' there at least. It's possible we may need to check the Python version and do things differently on 2 and 3 in the test, as well, but I think the .decode test should be enough for now.

101. By Diego Sarmentero

improve tests

102. By Diego Sarmentero

updating test

103. By Diego Sarmentero

removing unncessary lint ignore

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/devtools/runners/__init__.py'
--- ubuntuone/devtools/runners/__init__.py 2012-08-27 19:15:04 +0000
+++ ubuntuone/devtools/runners/__init__.py 2012-09-28 17:48:20 +0000
@@ -198,7 +198,7 @@
198 ['ignore-modules', 'i', '', None],198 ['ignore-modules', 'i', '', None],
199 ['ignore-paths', 'p', '', None],199 ['ignore-paths', 'p', '', None],
200 ['runner', None, 'txrunner', None],200 ['runner', None, 'txrunner', None],
201 ['temp-directory', None, '_trial_temp', None],201 ['temp-directory', None, b'_trial_temp', None],
202 ]202 ]
203203
204 def __init__(self, *args, **kwargs):204 def __init__(self, *args, **kwargs):
205205
=== added directory 'ubuntuone/devtools/runners/tests'
=== added file 'ubuntuone/devtools/runners/tests/__init__.py'
--- ubuntuone/devtools/runners/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/devtools/runners/tests/__init__.py 2012-09-28 17:48:20 +0000
@@ -0,0 +1,1 @@
1"""Test the dev tools."""
02
=== added file 'ubuntuone/devtools/runners/tests/test_base.py'
--- ubuntuone/devtools/runners/tests/test_base.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/devtools/runners/tests/test_base.py 2012-09-28 17:48:20 +0000
@@ -0,0 +1,39 @@
1# -*- coding: utf-8 *-*
2#
3# Copyright 2012 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16#
17# In addition, as a special exception, the copyright holders give
18# permission to link the code of portions of this program with the
19# OpenSSL library under certain conditions as described in each
20# individual source file, and distribute linked combinations
21# including the two.
22# You must obey the GNU General Public License in all respects
23# for all of the code used other than OpenSSL. If you modify
24# file(s) with this exception, you may extend this exception to your
25# version of the file(s), but you are not obligated to do so. If you
26# do not wish to do so, delete this exception statement from your
27# version. If you delete this exception statement from all source
28# files in the program, then also delete it here.
29"""Test the base module."""
30
31from ubuntuone.devtools.testcases import BaseTestCase
32
33
34class BaseRunnersTestCase(BaseTestCase):
35 """Test the runners module."""
36
37 def test_check_temp_directory_is_bytes(self):
38 """Check that the temp directory value is bytes."""
39 self.assertIsInstance(self.tmpdir, bytes)

Subscribers

People subscribed via source and target branches

to all changes: