Merge lp:~ralsina/ubuntu-sso-client/spawn-evil into lp:ubuntu-sso-client

Proposed by Roberto Alsina on 2012-03-15
Status: Merged
Approved by: Roberto Alsina on 2012-03-16
Approved revision: 918
Merged at revision: 918
Proposed branch: lp:~ralsina/ubuntu-sso-client/spawn-evil
Merge into: lp:ubuntu-sso-client
Diff against target: 51 lines (+16/-1)
2 files modified
ubuntu_sso/utils/__init__.py (+6/-0)
ubuntu_sso/utils/tests/test_common.py (+10/-1)
To merge this branch: bzr merge lp:~ralsina/ubuntu-sso-client/spawn-evil
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) 2012-03-15 Approve on 2012-03-16
dobey (community) Approve on 2012-03-15
Review via email: mp+97732@code.launchpad.net

Commit Message

 - Return the executable's dirname as BIN_DIR for frozen binaries (LP: #956187).

Description of the Change

 - Return the executable's dirname as BIN_DIR for frozen binaries (LP: #956187).

To post a comment you must log in.
Diego Sarmentero (diegosarmentero) wrote :

[FAIL]
Traceback (most recent call last):
  File "/media/gato/proyectos/canonical/ubuntu-sso-client-ralsina/ubuntu_sso/utils/tests/test_common.py", line 163, in test_frozen_binary
    self.assertEqual("foobar", result)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 270, in assertEqual
    % (msg, pformat(first), pformat(second)))
twisted.trial.unittest.FailTest: not equal:
a = 'foobar'
b = '/usr/bin'

ubuntu_sso.utils.tests.test_common.GetBinDirTestCase.test_frozen_binary
-------------------------------------------------------------------------------
Ran 775 tests in 31.097s

FAILED (skips=9, failures=1, successes=765)

review: Needs Fixing
918. By Roberto Alsina on 2012-03-15

oops

Roberto Alsina (ralsina) wrote :

oops, fixed.

dobey (dobey) :
review: Approve
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntu_sso/utils/__init__.py'
2--- ubuntu_sso/utils/__init__.py 2012-02-17 20:48:27 +0000
3+++ ubuntu_sso/utils/__init__.py 2012-03-15 20:05:21 +0000
4@@ -88,6 +88,12 @@
5 found, return the value of the BIN_DIR.
6
7 """
8+ # If sys is frozen, this is an .exe, and all binaries are in
9+ # the same place
10+ if hasattr(sys, "frozen"):
11+ exec_path = os.path.abspath(sys.executable)
12+ return os.path.dirname(exec_path)
13+
14 result = _get_dir(dir_name=BIN_SUFFIX, dir_constant='BIN_DIR')
15 assert result is not None, '%r dir can not be None.' % BIN_SUFFIX
16 return result
17
18=== modified file 'ubuntu_sso/utils/tests/test_common.py'
19--- ubuntu_sso/utils/tests/test_common.py 2012-02-15 20:21:52 +0000
20+++ ubuntu_sso/utils/tests/test_common.py 2012-03-15 20:05:21 +0000
21@@ -17,6 +17,7 @@
22 """Tests for the oauth_headers helper function."""
23
24 import logging
25+import os
26 import sys
27 import time
28
29@@ -146,13 +147,21 @@
30 self.assertEqual(expected, result)
31
32
33-class GetBinDirTestCase(TestCase):
34+class GetBinDirTestCase(GetProjectDirTestCase):
35 """Test case for get_bin_dir when constants module is not defined."""
36
37 DIR_NAME = utils.BIN_SUFFIX
38 DIR_CONSTANT = 'BIN_DIR'
39 DIR_GETTER = 'get_bin_dir'
40
41+ def test_frozen_binary(self):
42+ """Test that frozen binaries return a valid path."""
43+ sys.frozen = True
44+ self.addCleanup(delattr, sys, "frozen")
45+ expected = os.path.dirname(os.path.abspath(sys.executable))
46+ result = self.get_dir()
47+ self.assertEqual(expected, result)
48+
49
50 class GetBinDirWithConstantsTestCase(GetProjectDirWithConstantsTestCase):
51 """Test case for get_bin_dir when constants module is not defined."""

Subscribers

People subscribed via source and target branches