launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26276
[Merge] ~cjwatson/launchpad:py3-archivepublisher-doctests-future-imports into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-archivepublisher-doctests-future-imports into launchpad:master.
Commit message:
Convert lp.archivepublisher doctests to __future__ imports
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/397872
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-archivepublisher-doctests-future-imports into launchpad:master.
diff --git a/lib/lp/archivepublisher/tests/archive-signing.txt b/lib/lp/archivepublisher/tests/archive-signing.txt
index d61bd69..4bf9b93 100644
--- a/lib/lp/archivepublisher/tests/archive-signing.txt
+++ b/lib/lp/archivepublisher/tests/archive-signing.txt
@@ -41,7 +41,7 @@ Only PPAs with at least one source publication are considered.
>>> archive_set = getUtility(IArchiveSet)
>>> for ppa in archive_set.getPPAsPendingSigningKey():
- ... print ppa.displayname
+ ... print(ppa.displayname)
PPA for Celso Providelo
PPA for Mark Shuttleworth
@@ -52,13 +52,13 @@ why it's skipped in the getPPAsPendingSigningKey() results.
>>> cprov = getUtility(IPersonSet).getByName('cprov')
>>> no_priv = getUtility(IPersonSet).getByName('no-priv')
- >>> print no_priv.archive.displayname
+ >>> print(no_priv.archive.displayname)
PPA for No Privileges Person
>>> no_priv.archive.enabled
True
- >>> print no_priv.archive.signing_key
+ >>> print(no_priv.archive.signing_key)
None
>>> no_priv.archive.number_of_sources
@@ -72,7 +72,7 @@ we copy an arbitrary source into it.
... a_source.distroseries, a_source.pocket, no_priv.archive)
>>> for ppa in archive_set.getPPAsPendingSigningKey():
- ... print ppa.displayname
+ ... print(ppa.displayname)
PPA for Celso Providelo
PPA for Mark Shuttleworth
PPA for No Privileges Person
@@ -82,37 +82,37 @@ Disabled PPAs are excluded from the 'PendingSigningKey' pool:
>>> no_priv.archive.disable()
>>> for ppa in archive_set.getPPAsPendingSigningKey():
- ... print ppa.displayname
+ ... print(ppa.displayname)
PPA for Celso Providelo
PPA for Mark Shuttleworth
Indeed, Marks's PPA does not have a defined 'signing_key'.
>>> mark = getUtility(IPersonSet).getByName('mark')
- >>> print mark.archive.signing_key
+ >>> print(mark.archive.signing_key)
None
- >>> print mark.archive.signing_key_fingerprint
+ >>> print(mark.archive.signing_key_fingerprint)
None
We will select the only available IGPGKey from the sampledata.
>>> foo_bar = getUtility(IPersonSet).getByName('name16')
>>> [a_key] = foo_bar.gpg_keys
- >>> print a_key.displayname
+ >>> print(a_key.displayname)
1024D/ABCDEF0123456789ABCDDCBA0000111112345678
And use it as the Mark's PPA signing key.
>>> mark.archive.signing_key_owner = a_key.owner
>>> mark.archive.signing_key_fingerprint = a_key.fingerprint
- >>> print mark.archive.signing_key_fingerprint
+ >>> print(mark.archive.signing_key_fingerprint)
ABCDEF0123456789ABCDDCBA0000111112345678
It will exclude Mark's PPA from the 'PendingSigningKey' pool as well.
>>> for ppa in archive_set.getPPAsPendingSigningKey():
- ... print ppa.displayname
+ ... print(ppa.displayname)
PPA for Celso Providelo
@@ -123,7 +123,7 @@ As mentioned above, generated signing_keys will be stored in a
location defined by the system configuration.
>>> from lp.services.config import config
- >>> print config.personalpackagearchive.signing_keys_root
+ >>> print(config.personalpackagearchive.signing_keys_root)
/var/tmp/ppa-signing-keys.test
In order to manipulate 'signing_keys' securily the target archive
@@ -153,7 +153,7 @@ Once adapted `IArchiveGPGSigningKey` is properly implemented.
`IArchiveGPGSigningKey` object contain the corresponding IArchive
object.
- >>> print archive_signing_key.archive.displayname
+ >>> print(archive_signing_key.archive.displayname)
PPA for Celso Providelo
It also implements exportSecretKey() which receive a `PymeKey` and
@@ -181,8 +181,8 @@ in the expected path.
>>> mock_key = MockKey(True)
>>> archive_signing_key.exportSecretKey(mock_key)
- >>> print open(
- ... archive_signing_key.getPathForSecretKey(mock_key)).read()
+ >>> with open(archive_signing_key.getPathForSecretKey(mock_key)) as f:
+ ... print(f.read())
Secret True
At this point we can use the `IArchiveGPGSigningKey` to generate and
@@ -210,19 +210,19 @@ by the 'PPA key guard' celebrity and represented by a IGPGKey record.
>>> verifyObject(IGPGKey, signing_key)
True
- >>> print signing_key.owner.name
+ >>> print(signing_key.owner.name)
ppa-key-guard
- >>> print signing_key.algorithm.description
+ >>> print(signing_key.algorithm.description)
RSA
- >>> print signing_key.keysize
+ >>> print(signing_key.keysize)
1024
- >>> print signing_key.active
+ >>> print(signing_key.active)
True
- >>> print signing_key.can_encrypt
+ >>> print(signing_key.can_encrypt)
False
The generated key UID follows the "Launchpad PPA for %(person.displayname)s"
@@ -241,8 +241,8 @@ format.
The secret key is securily stored in the designed configuration
path. So only the IGPGHandler itself can access it.
- >>> print open(
- ... archive_signing_key.getPathForSecretKey(signing_key)).read()
+ >>> with open(archive_signing_key.getPathForSecretKey(signing_key)) as f:
+ ... print(f.read())
-----BEGIN PGP PRIVATE KEY BLOCK-----
...
-----END PGP PRIVATE KEY BLOCK-----
@@ -276,10 +276,10 @@ default PPA. We will create a named-ppa for Celso.
As expected it will use the same key used in Celso's default PPA.
- >>> print cprov.archive.signing_key.fingerprint
+ >>> print(cprov.archive.signing_key.fingerprint)
0D57E99656BEFB0897606EE9A022DD1F5001B46D
- >>> print named_ppa.signing_key.fingerprint
+ >>> print(named_ppa.signing_key.fingerprint)
0D57E99656BEFB0897606EE9A022DD1F5001B46D
We will reset the signing key of the just created named PPA,
@@ -293,7 +293,7 @@ created within the same cycle of the key-generator process.
>>> del get_property_cache(named_ppa).signing_key
>>> login(ANONYMOUS)
- >>> print named_ppa.signing_key
+ >>> print(named_ppa.signing_key)
None
Default PPAs are always created first and thus get their keys generated
@@ -306,10 +306,10 @@ the key generation procedure, as it would be normally in production.
Instead of generating a new key, the signing key from the default ppa
(Celso's default PPA) gets reused.
- >>> print cprov.archive.signing_key.fingerprint
+ >>> print(cprov.archive.signing_key.fingerprint)
0D57E99656BEFB0897606EE9A022DD1F5001B46D
- >>> print named_ppa.signing_key.fingerprint
+ >>> print(named_ppa.signing_key.fingerprint)
0D57E99656BEFB0897606EE9A022DD1F5001B46D
We will reset the signing-keys for both PPA of Celso.
@@ -323,10 +323,10 @@ We will reset the signing-keys for both PPA of Celso.
>>> del get_property_cache(named_ppa).signing_key
>>> login(ANONYMOUS)
- >>> print cprov.archive.signing_key
+ >>> print(cprov.archive.signing_key)
None
- >>> print named_ppa.signing_key
+ >>> print(named_ppa.signing_key)
None
Then modify the GPGHandler utility to return a sampledata key instead
@@ -334,7 +334,7 @@ of generating a new one, mainly for running the test faster and for
printing the context the key is generated.
>>> def mock_key_generator(name, logger=None):
- ... print 'Generating:', name
+ ... print('Generating:', name)
... key_path = os.path.join(gpgkeysdir, 'sign.only@xxxxxxxxxxxxxxxxx')
... return gpghandler.importSecretKey(open(key_path).read())
@@ -352,10 +352,10 @@ named after the user, even if the default PPA name is something different.
>>> named_ppa_signing_key.generateSigningKey()
Generating: Launchpad PPA for Not Celso Providelo
- >>> print cprov.archive.signing_key.fingerprint
+ >>> print(cprov.archive.signing_key.fingerprint)
447DBF38C4F9C4ED752246B77D88913717B05A8F
- >>> print named_ppa.signing_key.fingerprint
+ >>> print(named_ppa.signing_key.fingerprint)
447DBF38C4F9C4ED752246B77D88913717B05A8F
Restore the original functionality of GPGHandler.
@@ -403,14 +403,16 @@ file contents, and a clearsigned InRelease file.
>>> _ = archive_signing_key.signRepository(test_suite)
- >>> print open(release_path + '.gpg').read()
+ >>> with open(release_path + '.gpg') as f:
+ ... print(f.read())
-----BEGIN PGP SIGNATURE-----
...
-----END PGP SIGNATURE-----
<BLANKLINE>
>>> inline_release_path = os.path.join(suite_path, 'InRelease')
- >>> print open(inline_release_path).read()
+ >>> with open(inline_release_path) as f:
+ ... print(f.read())
-----BEGIN PGP SIGNED MESSAGE-----
...
-----BEGIN PGP SIGNATURE-----
@@ -439,7 +441,7 @@ keyserver.
... content=open(inline_release_path).read())
>>> inline_signature.fingerprint == expected_fingerprint
True
- >>> print inline_signature.plain_data
+ >>> print(inline_signature.plain_data)
This is a fake release file.
<BLANKLINE>
diff --git a/lib/lp/archivepublisher/tests/deathrow.txt b/lib/lp/archivepublisher/tests/deathrow.txt
index 7bb3c7e..3ca510a 100644
--- a/lib/lp/archivepublisher/tests/deathrow.txt
+++ b/lib/lp/archivepublisher/tests/deathrow.txt
@@ -218,9 +218,9 @@ the temporary repository.
>>> def check_pool_files():
... for file_path in all_test_file_paths:
... if os.path.exists(file_path):
- ... print '%s: OK' % os.path.basename(file_path)
+ ... print('%s: OK' % os.path.basename(file_path))
... else:
- ... print '%s: REMOVED' % os.path.basename(file_path)
+ ... print('%s: REMOVED' % os.path.basename(file_path))
>>> check_pool_files()
deleted-bin_666_i386.deb: OK
@@ -282,7 +282,7 @@ status was preserved in the database.
>>> def check_removed(pub):
... properly_removed = pub.dateremoved is not None
- ... print pub.displayname, pub.status.name, properly_removed
+ ... print(pub.displayname, pub.status.name, properly_removed)
>>> for pub in removed_records:
... check_removed(pub)
diff --git a/lib/lp/archivepublisher/tests/test_publisher_documentation.py b/lib/lp/archivepublisher/tests/test_publisher_documentation.py
index bc2b7d6..1091cd1 100644
--- a/lib/lp/archivepublisher/tests/test_publisher_documentation.py
+++ b/lib/lp/archivepublisher/tests/test_publisher_documentation.py
@@ -22,7 +22,7 @@ from lp.testing.systemdocs import (
def archivePublisherSetUp(test):
- setUp(test)
+ setUp(test, future=True)
switch_dbuser(config.archivepublisher.dbuser)