* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2011-07-01 8:50 Zac Medico
0 siblings, 0 replies; 11+ messages in thread
From: Zac Medico @ 2011-07-01 8:50 UTC (permalink / raw
To: gentoo-commits
commit: b243747fff40fb061041db58c149bef4b89e6771
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 1 08:50:07 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jul 1 08:50:07 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b243747f
Fix a typo in a comment.
---
pym/portage/tests/util/test_varExpand.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pym/portage/tests/util/test_varExpand.py b/pym/portage/tests/util/test_varExpand.py
index 4af8f80..7b528d6 100644
--- a/pym/portage/tests/util/test_varExpand.py
+++ b/pym/portage/tests/util/test_varExpand.py
@@ -27,7 +27,7 @@ class VarExpandTestCase(TestCase):
assignment in a sourced file, in which case it performs
backslash removal for \\ and \$ but nothing more. It also
removes escaped newline characters. Note that we don't
- handle escaped quotes here, since genconfig() uses shlex
+ handle escaped quotes here, since getconfig() uses shlex
to handle that earlier.
"""
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2011-10-05 3:22 Zac Medico
0 siblings, 0 replies; 11+ messages in thread
From: Zac Medico @ 2011-10-05 3:22 UTC (permalink / raw
To: gentoo-commits
commit: 20c2032f65c4a0bb7a523d8c5eaf46562e4cd35b
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 5 03:20:54 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 5 03:22:07 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=20c2032f
Execute tests bundled with the whirlpool module.
---
pym/portage/tests/util/test_whirlpool.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/pym/portage/tests/util/test_whirlpool.py b/pym/portage/tests/util/test_whirlpool.py
new file mode 100644
index 0000000..dd0de89
--- /dev/null
+++ b/pym/portage/tests/util/test_whirlpool.py
@@ -0,0 +1,16 @@
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import subprocess
+
+import portage
+from portage import os
+from portage.const import PORTAGE_PYM_PATH
+from portage.tests import TestCase
+
+class WhirlpoolTestCase(TestCase):
+ def testBundledWhirlpool(self):
+ # execute the tests bundled with the whirlpool module
+ retval = subprocess.call([portage._python_interpreter, "-Wd",
+ os.path.join(PORTAGE_PYM_PATH, "portage/util/whirlpool.py")])
+ self.assertEqual(retval, os.EX_OK)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2011-12-02 2:07 Zac Medico
0 siblings, 0 replies; 11+ messages in thread
From: Zac Medico @ 2011-12-02 2:07 UTC (permalink / raw
To: gentoo-commits
commit: 1776d5db74e7065b409b7e2d521323e8d7ea2bb5
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 2 02:07:21 2011 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Dec 2 02:07:21 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=1776d5db
test_uniqueArray.py: fix 'is' usage PyPy incompat
---
pym/portage/tests/util/test_uniqueArray.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/pym/portage/tests/util/test_uniqueArray.py b/pym/portage/tests/util/test_uniqueArray.py
index 2a1a209..e23428c 100644
--- a/pym/portage/tests/util/test_uniqueArray.py
+++ b/pym/portage/tests/util/test_uniqueArray.py
@@ -1,5 +1,5 @@
# test_uniqueArray.py -- Portage Unit Testing Functionality
-# Copyright 2006 Gentoo Foundation
+# Copyright 2006-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage import os
@@ -20,5 +20,5 @@ class UniqueArrayTestCase(TestCase):
result = unique_array( test[0] )
for item in test[1]:
number = result.count(item)
- self.assertFalse( number is not 1, msg="%s contains %s of %s, \
- should be only 1" % (result, number, item) )
+ self.assertFalse( number != 1, msg=("%s contains %s of %s, "
+ "should be only 1") % (result, number, item) )
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2012-04-03 16:06 Zac Medico
0 siblings, 0 replies; 11+ messages in thread
From: Zac Medico @ 2012-04-03 16:06 UTC (permalink / raw
To: gentoo-commits
commit: c521bc87db7daf70a6c00272c6c7440059135b58
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 3 16:06:38 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Apr 3 16:06:38 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c521bc87
test_getconfig: add case for bug #410625
---
pym/portage/tests/util/test_getconfig.py | 26 +++++++++++++++++++++++++-
1 files changed, 25 insertions(+), 1 deletions(-)
diff --git a/pym/portage/tests/util/test_getconfig.py b/pym/portage/tests/util/test_getconfig.py
index 00f7f52..f13b753 100644
--- a/pym/portage/tests/util/test_getconfig.py
+++ b/pym/portage/tests/util/test_getconfig.py
@@ -1,7 +1,10 @@
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import tempfile
+
from portage import os
+from portage import _unicode_encode
from portage.const import PORTAGE_BASE_PATH
from portage.tests import TestCase
from portage.util import getconfig
@@ -27,3 +30,24 @@ class GetConfigTestCase(TestCase):
d = getconfig(make_globals_file)
for k, v in self._cases.items():
self.assertEqual(d[k], v)
+
+ def testGetConfigProfileEnv(self):
+ # Test the mode which is used to parse /etc/env.d and /etc/profile.env.
+
+ cases = {
+ 'LESS_TERMCAP_mb': "$\E[01;31m", # bug #410625
+ }
+
+ with tempfile.NamedTemporaryFile(mode='wb') as f:
+ # Format like env_update formats /etc/profile.env.
+ for k, v in cases.items():
+ if v.startswith('$') and not v.startswith('${'):
+ line = "export %s=$'%s'\n" % (k, v[1:])
+ else:
+ line = "export %s='%s'\n" % (k, v)
+ f.write(_unicode_encode(line))
+ f.flush()
+
+ d = getconfig(f.name, expand=False)
+ for k, v in cases.items():
+ self.assertEqual(d.get(k), v)
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2012-05-12 19:27 Zac Medico
0 siblings, 0 replies; 11+ messages in thread
From: Zac Medico @ 2012-05-12 19:27 UTC (permalink / raw
To: gentoo-commits
commit: e2987dfe6c2c0a83adeeb40979a5bf1843db8223
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 12 19:27:17 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 12 19:27:17 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e2987dfe
test_stackLists: fix for PYTHONHASHSEED="random"
---
pym/portage/tests/util/test_stackLists.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pym/portage/tests/util/test_stackLists.py b/pym/portage/tests/util/test_stackLists.py
index 8d01ea5..fe61856 100644
--- a/pym/portage/tests/util/test_stackLists.py
+++ b/pym/portage/tests/util/test_stackLists.py
@@ -16,4 +16,4 @@ class StackListsTestCase(TestCase):
for test in tests:
result = stack_lists( test[0], test[2] )
- self.assertEqual( result , test[1] )
+ self.assertEqual( set(result) , set(test[1]) )
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2012-05-12 19:30 Zac Medico
0 siblings, 0 replies; 11+ messages in thread
From: Zac Medico @ 2012-05-12 19:30 UTC (permalink / raw
To: gentoo-commits
commit: b4722008c1bf425a334c885be0a93535dcb88b36
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 12 19:27:17 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 12 19:30:12 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b4722008
test_stackLists: fix for PYTHONHASHSEED="random"
---
pym/portage/tests/util/test_stackLists.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pym/portage/tests/util/test_stackLists.py b/pym/portage/tests/util/test_stackLists.py
index 8d01ea5..e524772 100644
--- a/pym/portage/tests/util/test_stackLists.py
+++ b/pym/portage/tests/util/test_stackLists.py
@@ -1,5 +1,5 @@
# test_stackLists.py -- Portage Unit Testing Functionality
-# Copyright 2006 Gentoo Foundation
+# Copyright 2006-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
@@ -16,4 +16,4 @@ class StackListsTestCase(TestCase):
for test in tests:
result = stack_lists( test[0], test[2] )
- self.assertEqual( result , test[1] )
+ self.assertEqual( set(result) , set(test[1]) )
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2012-05-12 21:11 Zac Medico
0 siblings, 0 replies; 11+ messages in thread
From: Zac Medico @ 2012-05-12 21:11 UTC (permalink / raw
To: gentoo-commits
commit: ae95697010a331a98fe112bdac565c3dcbcd3160
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 12 21:11:32 2012 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 12 21:11:32 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ae956970
test_digraph: fix bfs for PYTHONHASHSEED=random
---
pym/portage/tests/util/test_digraph.py | 43 +++++++++++++++++++++++++++++---
1 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/pym/portage/tests/util/test_digraph.py b/pym/portage/tests/util/test_digraph.py
index b65c0b1..4fb1f95 100644
--- a/pym/portage/tests/util/test_digraph.py
+++ b/pym/portage/tests/util/test_digraph.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Gentoo Foundation
+# Copyright 2010-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
@@ -8,6 +8,41 @@ import portage.util
class DigraphTest(TestCase):
+ def _assertBFSEqual(self, result, expected):
+ result_stack = list(result)
+ result_stack.reverse()
+ expected_stack = list(reversed(expected))
+ result_compared = []
+ expected_compared = []
+ while result_stack:
+ if not expected_stack:
+ result_compared.append(result_stack.pop())
+ self.assertEqual(result_compared, expected_compared)
+ expected_set = expected_stack.pop()
+ if not isinstance(expected_set, list):
+ expected_set = [expected_set]
+ expected_set = set(expected_set)
+ while expected_set:
+ if not result_stack:
+ expected_compared.extend(expected_set)
+ self.assertEqual(result_compared, expected_compared)
+ obj = result_stack.pop()
+ try:
+ expected_set.remove(obj)
+ except KeyError:
+ expected_compared.extend(expected_set)
+ result_compared.append(obj)
+ self.assertEqual(result_compared, expected_compared)
+ else:
+ expected_compared.append(obj)
+ result_compared.append(obj)
+ if expected_stack:
+ expected_set = expected_stack.pop()
+ if not isinstance(expected_set, list):
+ expected_set = [expected_set]
+ expected_compared.extend(expected_set)
+ self.assertEqual(result_compared, expected_compared)
+
def testBackwardCompatibility(self):
g = digraph()
f = g.copy()
@@ -71,7 +106,7 @@ class DigraphTest(TestCase):
self.assertEqual(x.parent_nodes("A", ignore_priority=-2), ["B"])
self.assertEqual(x.parent_nodes("A", ignore_priority=-1), [])
self.assertEqual(x.hasallzeros(), False)
- self.assertEqual(list(x.bfs("A")), [(None, "A"), ("A", "D"), ("D", "C"), ("C", "B")])
+ self._assertBFSEqual(x.bfs("A"), [(None, "A"), ("A", "D"), ("D", "C"), ("C", "B")])
self.assertEqual(x.shortest_path("A", "D"), ["A", "D"])
self.assertEqual(x.shortest_path("D", "A"), ["D", "C", "B", "A"])
self.assertEqual(x.shortest_path("A", "D", ignore_priority=2), None)
@@ -115,7 +150,7 @@ class DigraphTest(TestCase):
self.assertEqual(x.parent_nodes("B", ignore_priority=-2), ["A"])
self.assertEqual(x.parent_nodes("B", ignore_priority=-1), [])
self.assertEqual(x.hasallzeros(), False)
- self.assertEqual(list(x.bfs("A")), [(None, "A"), ("A", "C"), ("A", "B"), ("C", "E"), ("C", "D")])
+ self._assertBFSEqual(x.bfs("A"), [(None, "A"), [("A", "C"), ("A", "B")], [("C", "E"), ("C", "D")]])
self.assertEqual(x.shortest_path("A", "D"), ["A", "C", "D"])
self.assertEqual(x.shortest_path("D", "A"), None)
self.assertEqual(x.shortest_path("A", "D", ignore_priority=2), None)
@@ -158,7 +193,7 @@ class DigraphTest(TestCase):
self.assertEqual(x.parent_nodes("A", ignore_priority=0), ["C"])
self.assertEqual(x.parent_nodes("A", ignore_priority=1), [])
self.assertEqual(x.hasallzeros(), False)
- self.assertEqual(list(x.bfs("A")), [(None, "A"), ("A", "C"), ("A", "B")])
+ self._assertBFSEqual(x.bfs("A"), [(None, "A"), [("A", "C"), ("A", "B")]])
self.assertEqual(x.shortest_path("A", "C"), ["A", "C"])
self.assertEqual(x.shortest_path("C", "A"), ["C", "A"])
self.assertEqual(x.shortest_path("A", "C", ignore_priority=0), ["A", "B", "C"])
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2013-05-18 23:53 Zac Medico
0 siblings, 0 replies; 11+ messages in thread
From: Zac Medico @ 2013-05-18 23:53 UTC (permalink / raw
To: gentoo-commits
commit: 8e0f1cece962b7bebffad45cbd24b8045d5e9838
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat May 18 23:53:01 2013 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat May 18 23:53:01 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8e0f1cec
test_getconfig: sync FETCHCOMMAND_SFTP/SSH
---
pym/portage/tests/util/test_getconfig.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pym/portage/tests/util/test_getconfig.py b/pym/portage/tests/util/test_getconfig.py
index f13b753..c7ab360 100644
--- a/pym/portage/tests/util/test_getconfig.py
+++ b/pym/portage/tests/util/test_getconfig.py
@@ -18,8 +18,8 @@ class GetConfigTestCase(TestCase):
_cases = {
'FETCHCOMMAND' : 'wget -t 3 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}"',
'FETCHCOMMAND_RSYNC' : 'rsync -avP "${URI}" "${DISTDIR}/${FILE}"',
- 'FETCHCOMMAND_SFTP' : 'bash -c "x=\\${2#sftp://} ; host=\\${x%%/*} ; port=\\${host##*:} ; host=\\${host%:*} ; [[ \\${host} = \\${port} ]] && port=22 ; exec sftp -P \\${port} \\"\\${host}:/\\${x#*/}\\" \\"\\$1\\"" sftp "${DISTDIR}/${FILE}" "${URI}"',
- 'FETCHCOMMAND_SSH' : 'bash -c "x=\\${2#ssh://} ; host=\\${x%%/*} ; port=\\${host##*:} ; host=\\${host%:*} ; [[ \\${host} = \\${port} ]] && port=22 ; exec rsync --rsh=\\"ssh -p\\${port}\\" -avP \\"\\${host}:/\\${x#*/}\\" \\"\\$1\\"" rsync "${DISTDIR}/${FILE}" "${URI}"',
+ 'FETCHCOMMAND_SFTP' : 'bash -c "x=\\${2#sftp://} ; host=\\${x%%/*} ; port=\\${host##*:} ; host=\\${host%:*} ; [[ \\${host} = \\${port} ]] && port=22 ; eval \\"declare -a ssh_opts=(\\${3})\\" ; exec sftp -P \\${port} \\"\\${ssh_opts[@]}\\" \\"\\${host}:/\\${x#*/}\\" \\"\\$1\\"" sftp "${DISTDIR}/${FILE}" "${URI}" "${PORTAGE_SSH_OPTS}"',
+ 'FETCHCOMMAND_SSH' : 'bash -c "x=\\${2#ssh://} ; host=\\${x%%/*} ; port=\\${host##*:} ; host=\\${host%:*} ; [[ \\${host} = \\${port} ]] && port=22 ; exec rsync --rsh=\\"ssh -p\\${port} \\${3}\\" -avP \\"\\${host}:/\\${x#*/}\\" \\"\\$1\\"" rsync "${DISTDIR}/${FILE}" "${URI}" "${PORTAGE_SSH_OPTS}"',
'PORTAGE_ELOG_MAILSUBJECT' : '[portage] ebuild log for ${PACKAGE} on ${HOST}'
}
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2014-01-26 4:06 Arfrever Frehtes Taifersar Arahesis
0 siblings, 0 replies; 11+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2014-01-26 4:06 UTC (permalink / raw
To: gentoo-commits
commit: 2582e0e40b759f191341a2d730aceab558dfdf72
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sun Jan 26 04:05:11 2014 +0000
Commit: Arfrever Frehtes Taifersar Arahesis <arfrever <AT> apache <DOT> org>
CommitDate: Sun Jan 26 04:05:11 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2582e0e4
Fix test with Python 2.6.
(assertIsNotNone was introduced in Python 2.7 and 3.1.)
---
pym/portage/tests/util/test_getconfig.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pym/portage/tests/util/test_getconfig.py b/pym/portage/tests/util/test_getconfig.py
index e7b638f..f1584c5 100644
--- a/pym/portage/tests/util/test_getconfig.py
+++ b/pym/portage/tests/util/test_getconfig.py
@@ -42,7 +42,7 @@ class GetConfigTestCase(TestCase):
allow_sourcing=True, expand={"PORTAGE_BASE_PATH" : base})
# PASSES_SOURCING_TEST should exist in getconfig result
- self.assertIsNotNone(d)
+ self.assertTrue(d is not None)
self.assertEqual("True", d['PASSES_SOURCING_TEST'])
# With allow_sourcing : True and empty expand map, this should
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2014-02-02 4:11 Arfrever Frehtes Taifersar Arahesis
0 siblings, 0 replies; 11+ messages in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2014-02-02 4:11 UTC (permalink / raw
To: gentoo-commits
commit: 2411ec3a11ecf53cb1725c0282797d8d0e40ecbc
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Sun Feb 2 04:10:01 2014 +0000
Commit: Arfrever Frehtes Taifersar Arahesis <arfrever <AT> apache <DOT> org>
CommitDate: Sun Feb 2 04:10:01 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2411ec3a
portage.tests.util.test_getconfig.GetConfigTestCase.testGetConfigSourceLex(): Embed contents of test files in test function itself.
---
.../tests/util/make.conf.example.source_test | 6 ----
.../tests/util/make.conf.example.source_test_after | 7 -----
pym/portage/tests/util/test_getconfig.py | 33 +++++++++++++---------
3 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/pym/portage/tests/util/make.conf.example.source_test b/pym/portage/tests/util/make.conf.example.source_test
deleted file mode 100644
index c0b1c16..0000000
--- a/pym/portage/tests/util/make.conf.example.source_test
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# Contains local system settings for Portage system
-
-# Test make.conf for variable expansion in source tokens.
-source "$PORTAGE_BASE_PATH/make.conf.example.source_test_after"
diff --git a/pym/portage/tests/util/make.conf.example.source_test_after b/pym/portage/tests/util/make.conf.example.source_test_after
deleted file mode 100644
index e41913e..0000000
--- a/pym/portage/tests/util/make.conf.example.source_test_after
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 1999-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# Contains local system settings for Portage system
-
-# Test make.conf for variable expansion in source tokens.
-# We should see this variable in getconfig result
-PASSES_SOURCING_TEST="True"
diff --git a/pym/portage/tests/util/test_getconfig.py b/pym/portage/tests/util/test_getconfig.py
index f1584c5..e5fd60f 100644
--- a/pym/portage/tests/util/test_getconfig.py
+++ b/pym/portage/tests/util/test_getconfig.py
@@ -4,6 +4,7 @@
import tempfile
from portage import os
+from portage import shutil
from portage import _unicode_encode
from portage.const import PORTAGE_BASE_PATH
from portage.tests import TestCase
@@ -33,23 +34,27 @@ class GetConfigTestCase(TestCase):
self.assertEqual(d[k], v)
def testGetConfigSourceLex(self):
+ try:
+ tempdir = tempfile.mkdtemp()
+ make_conf_file = os.path.join(tempdir, 'make.conf')
+ with open(make_conf_file, 'w') as f:
+ f.write('source "${DIR}/sourced_file"\n')
+ sourced_file = os.path.join(tempdir, 'sourced_file')
+ with open(sourced_file, 'w') as f:
+ f.write('PASSES_SOURCING_TEST="True"\n')
- base = os.path.dirname(__file__)
- make_conf_file = os.path.join(base,
- 'make.conf.example.source_test')
+ d = getconfig(make_conf_file, allow_sourcing=True, expand={"DIR": tempdir})
- d = getconfig(make_conf_file,
- allow_sourcing=True, expand={"PORTAGE_BASE_PATH" : base})
+ # PASSES_SOURCING_TEST should exist in getconfig result.
+ self.assertTrue(d is not None)
+ self.assertEqual("True", d['PASSES_SOURCING_TEST'])
- # PASSES_SOURCING_TEST should exist in getconfig result
- self.assertTrue(d is not None)
- self.assertEqual("True", d['PASSES_SOURCING_TEST'])
-
- # With allow_sourcing : True and empty expand map, this should
- # Throw a FileNotFound exception
- self.assertRaisesMsg("An empty expand map should throw an exception",
- ParseError, getconfig, *(make_conf_file,),
- **{'allow_sourcing' : True, 'expand' : {}})
+ # With allow_sourcing=True and empty expand map, this should
+ # throw a FileNotFound exception.
+ self.assertRaisesMsg("An empty expand map should throw an exception",
+ ParseError, getconfig, make_conf_file, allow_sourcing=True, expand={})
+ finally:
+ shutil.rmtree(tempdir)
def testGetConfigProfileEnv(self):
# Test the mode which is used to parse /etc/env.d and /etc/profile.env.
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/
@ 2017-03-13 21:46 Michał Górny
0 siblings, 0 replies; 11+ messages in thread
From: Michał Górny @ 2017-03-13 21:46 UTC (permalink / raw
To: gentoo-commits
commit: 04c2bbaba38e766250fee019fd9bbb98ba582038
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 12 15:12:48 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Mar 13 21:46:29 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=04c2bbab
tests: Add minimal safety checks for checksums
pym/portage/tests/util/test_checksum.py | 88 +++++++++++++++++++++++++++++++++
1 file changed, 88 insertions(+)
diff --git a/pym/portage/tests/util/test_checksum.py b/pym/portage/tests/util/test_checksum.py
new file mode 100644
index 000000000..72b8cef3f
--- /dev/null
+++ b/pym/portage/tests/util/test_checksum.py
@@ -0,0 +1,88 @@
+# Copyright 2011-2017 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from portage.tests import TestCase
+
+from portage.checksum import checksum_str
+from portage.exception import DigestException
+
+class ChecksumTestCase(TestCase):
+ text = b'Some test string used to check if the hash works'
+
+ def test_md5(self):
+ self.assertEqual(checksum_str(b'', 'MD5'),
+ 'd41d8cd98f00b204e9800998ecf8427e')
+ self.assertEqual(checksum_str(self.text, 'MD5'),
+ '094c3bf4732f59b39d577e9726f1e934')
+
+ def test_sha1(self):
+ self.assertEqual(checksum_str(b'', 'SHA1'),
+ 'da39a3ee5e6b4b0d3255bfef95601890afd80709')
+ self.assertEqual(checksum_str(self.text, 'SHA1'),
+ '5c572017d4e4d49e4aa03a2eda12dbb54a1e2e4f')
+
+ def test_sha256(self):
+ self.assertEqual(checksum_str(b'', 'SHA256'),
+ 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')
+ self.assertEqual(checksum_str(self.text, 'SHA256'),
+ 'e3d4a1135181fe156d61455615bb6296198e8ca5b2f20ddeb85cb4cd27f62320')
+
+ def test_sha512(self):
+ self.assertEqual(checksum_str(b'', 'SHA512'),
+ 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e')
+ self.assertEqual(checksum_str(self.text, 'SHA512'),
+ 'c8eaa902d48a2c82c2185a92f1c8bab8115c63c8d7a9966a8e8e81b07abcb9762f4707a6b27075e9d720277ba9fec072a59840d6355dd2ee64681d8f39a50856')
+
+ def test_rmd160(self):
+ try:
+ self.assertEqual(checksum_str(b'', 'RMD160'),
+ '9c1185a5c5e9fc54612808977ee8f548b2258d31')
+ self.assertEqual(checksum_str(self.text, 'RMD160'),
+ 'fc453174f63fc011d6f64abd2c45fb6a53c8239b')
+ except DigestException:
+ self.skipTest('RMD160 implementation not available')
+
+ def test_whirlpool(self):
+ try:
+ self.assertEqual(checksum_str(b'', 'WHIRLPOOL'),
+ '19fa61d75522a4669b44e39c1d2e1726c530232130d407f89afee0964997f7a73e83be698b288febcf88e3e03c4f0757ea8964e59b63d93708b138cc42a66eb3')
+ self.assertEqual(checksum_str(self.text, 'WHIRLPOOL'),
+ '8f556a079b87057f19e0880eed6d833e40c916f4b133196f6842281a2517873074d399832470c11ee251696b4844a10197714a069ba3e3415c8a4eced8f91b48')
+ except DigestException:
+ self.skipTest('WHIRLPOOL implementation not available')
+
+ def test_blake2b(self):
+ try:
+ self.assertEqual(checksum_str(b'', 'BLAKE2B'),
+ '786a02f742015903c6c6fd852552d272912f4740e15847618a86e217f71f5419d25e1031afee585313896444934eb04b903a685b1448b755d56f701afe9be2ce')
+ self.assertEqual(checksum_str(self.text, 'BLAKE2B'),
+ '84cb3c88838c7147bc9797c6525f812adcdcb40137f9c075963e3a3ed1fe06aaeeb4d2bb5589bad286864dc1aa834cfc4d66b8d7e4d4a246d91d45ce3a6eee43')
+ except DigestException:
+ self.skipTest('BLAKE2B implementation not available')
+
+ def test_blake2s(self):
+ try:
+ self.assertEqual(checksum_str(b'', 'BLAKE2S'),
+ '69217a3079908094e11121d042354a7c1f55b6482ca1a51e1b250dfd1ed0eef9')
+ self.assertEqual(checksum_str(self.text, 'BLAKE2S'),
+ '823ab2429f27690450efe888b0404d092fe2ee72a9bd63d5342c251b4dbb373d')
+ except DigestException:
+ self.skipTest('BLAKE2S implementation not available')
+
+ def test_sha3_256(self):
+ try:
+ self.assertEqual(checksum_str(b'', 'SHA3_256'),
+ 'a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')
+ self.assertEqual(checksum_str(self.text, 'SHA3_256'),
+ '932fc0498ebb865406f9b6606280939283aa8a148562e39fd095a5d22bdec5c6')
+ except DigestException:
+ self.skipTest('SHA3_256 implementation not available')
+
+ def test_sha3_512(self):
+ try:
+ self.assertEqual(checksum_str(b'', 'SHA3_512'),
+ 'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26')
+ self.assertEqual(checksum_str(self.text, 'SHA3_512'),
+ '6634c004dc31822fa65c2f1e2e3bbf0cfa35085653cca1ca9ca42f8f3f13c908405e0b665918146181c9fc9a9d793fc05429d669c35a55517820dfaa071425ca')
+ except DigestException:
+ self.skipTest('SHA3_512 implementation not available')
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-03-13 21:47 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-02 2:07 [gentoo-commits] proj/portage:master commit in: pym/portage/tests/util/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2017-03-13 21:46 Michał Górny
2014-02-02 4:11 Arfrever Frehtes Taifersar Arahesis
2014-01-26 4:06 Arfrever Frehtes Taifersar Arahesis
2013-05-18 23:53 Zac Medico
2012-05-12 21:11 Zac Medico
2012-05-12 19:30 Zac Medico
2012-05-12 19:27 Zac Medico
2012-04-03 16:06 Zac Medico
2011-10-05 3:22 Zac Medico
2011-07-01 8:50 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox