diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-10-17 19:54:55 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-10-17 19:54:55 +0100 |
commit | 6961416a28270d3483d7ffd73539294cdb874403 (patch) | |
tree | 8caed7f40daeca490974938b701781a231b02ccc | |
parent | 7bfd144ed0a1885ee9c4c4664a9bc82352af2937 (diff) | |
download | morph-6961416a28270d3483d7ffd73539294cdb874403.tar.gz |
Move Builder.arch into util.arch.
This makes it easy to add a test case.
-rw-r--r-- | morphlib/builder.py | 6 | ||||
-rw-r--r-- | morphlib/util.py | 9 | ||||
-rw-r--r-- | morphlib/util_tests.py | 8 |
3 files changed, 18 insertions, 5 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py index 76c234a6..bc51ab19 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -52,10 +52,6 @@ class Builder(object): self.settings = settings self.cachedir = morphlib.cachedir.CacheDir(settings['cachedir']) - @property - def arch(self): - return os.uname()[4] - def build(self, morph): '''Build a binary based on a morphology.''' if morph.kind == 'chunk': @@ -174,7 +170,7 @@ class Builder(object): dict_key = { 'name': name, 'kind': kind, - 'arch': self.arch, + 'arch': morphlib.util.arch(), 'repo': repo, 'ref': abs_ref, } diff --git a/morphlib/util.py b/morphlib/util.py index 850d943f..430fdc20 100644 --- a/morphlib/util.py +++ b/morphlib/util.py @@ -17,6 +17,15 @@ '''Utility functions for morph.''' +import os + + +def arch(): + '''Return the CPU architecture of the current host.''' + return os.uname()[4] + + + def indent(string, spaces=4): '''Return ``string`` indented by ``spaces`` spaces. diff --git a/morphlib/util_tests.py b/morphlib/util_tests.py index 5b1d5e88..6637f571 100644 --- a/morphlib/util_tests.py +++ b/morphlib/util_tests.py @@ -19,6 +19,14 @@ import unittest import morphlib +class ArchTests(unittest.TestCase): + + def test(self): + arch = morphlib.util.arch() + self.assertEqual(type(arch), str) + self.assertNotEqual(arch, '') + + class IndentTests(unittest.TestCase): def test_returns_empty_string_for_empty_string(self): |