1414import os
1515import shutil
1616
17- from tracemalloc import Snapshot
18-
1917import pretend
2018import pytest
2119
2220from securesystemslib .exceptions import StorageError
2321from zope .interface .verify import verifyClass
2422
2523from warehouse .config import Environment
26- from warehouse .tuf import hash_bins , includeme , services
24+ from warehouse .tuf import services
2725from warehouse .tuf .constants import BIN_N_COUNT , Role
2826from warehouse .tuf .hash_bins import HashBins
2927from warehouse .tuf .interfaces import IKeyService , IRepositoryService , IStorageService
30- from warehouse .tuf .repository import RolesPayload , TargetsPayload
28+ from warehouse .tuf .repository import TargetsPayload
3129
3230
3331class TestLocalKeyService :
@@ -131,7 +129,7 @@ def test_get_oserror(self, monkeypatch):
131129 )
132130
133131 with pytest .raises (StorageError ) as err :
134- with service .get ("root" ) as r :
132+ with service .get ("root" ):
135133 pass
136134
137135 assert "Can't open /opt/warehouse/src/dev/metadata/1.root.json" in str (
@@ -454,7 +452,7 @@ def test_init_repository(self, db_request, monkeypatch):
454452 result = service .init_repository ()
455453
456454 call_args = fake_metadata_repository .initialize .calls [0 ].args [0 ]
457- assert result == None
455+ assert result is None
458456 assert str (call_args ["snapshot" ].expiration ) == "2019-06-17 09:05:01"
459457 assert str (call_args ["timestamp" ].expiration ) == "2019-06-17 09:05:01"
460458 assert str (call_args ["root" ].expiration ) == "2020-06-15 09:05:01"
@@ -474,18 +472,18 @@ def test_init_repository(self, db_request, monkeypatch):
474472 assert call_args ["timestamp" ].keys == "fake_key"
475473 assert call_args ["root" ].keys == "fake_key"
476474 assert call_args ["targets" ].keys == "fake_key"
477- assert call_args ["snapshot" ].delegation_role == None
478- assert call_args ["timestamp" ].delegation_role == None
479- assert call_args ["root" ].delegation_role == None
480- assert call_args ["targets" ].delegation_role == None
481- assert call_args ["snapshot" ].paths == None
482- assert call_args ["timestamp" ].paths == None
483- assert call_args ["root" ].paths == None
484- assert call_args ["targets" ].paths == None
485- assert call_args ["snapshot" ].path_hash_prefixes == None
486- assert call_args ["timestamp" ].path_hash_prefixes == None
487- assert call_args ["root" ].path_hash_prefixes == None
488- assert call_args ["targets" ].path_hash_prefixes == None
475+ assert call_args ["snapshot" ].delegation_role is None
476+ assert call_args ["timestamp" ].delegation_role is None
477+ assert call_args ["root" ].delegation_role is None
478+ assert call_args ["targets" ].delegation_role is None
479+ assert call_args ["snapshot" ].paths is None
480+ assert call_args ["timestamp" ].paths is None
481+ assert call_args ["root" ].paths is None
482+ assert call_args ["targets" ].paths is None
483+ assert call_args ["snapshot" ].path_hash_prefixes is None
484+ assert call_args ["timestamp" ].path_hash_prefixes is None
485+ assert call_args ["root" ].path_hash_prefixes is None
486+ assert call_args ["targets" ].path_hash_prefixes is None
489487 for test_call in [
490488 pretend .call (Role .SNAPSHOT .value ),
491489 pretend .call (Role .ROOT .value ),
@@ -553,7 +551,7 @@ def test_init_targets_delegation(self, db_request, monkeypatch):
553551 result = service .init_targets_delegation ()
554552 call_args = fake_metadata_repository .delegate_targets_roles .calls [0 ].args [0 ]
555553
556- assert result == None
554+ assert result is None
557555 assert sorted (["targets" , "bins" ]) == sorted (list (call_args .keys ()))
558556 assert len (call_args ["targets" ]) == 1
559557 assert call_args ["targets" ][0 ].paths == ["*/*" , "*/*/*/*" ]
@@ -603,7 +601,7 @@ def test_bump_snapshot(self, db_request, monkeypatch):
603601 bump_s_calls = fake_metadata_repository .snapshot_bump_version .calls [0 ].kwargs
604602 bump_t_calls = fake_metadata_repository .timestamp_bump_version .calls [0 ].kwargs
605603
606- assert result == None
604+ assert result is None
607605 assert fake_metadata_repository .load_role .calls == [pretend .call ("snapshot" )]
608606 assert str (bump_s_calls ["snapshot_expires" ]) == "2019-06-17 09:05:01"
609607 assert bump_s_calls ["snapshot_metadata" ].signed .version == 2
@@ -647,7 +645,7 @@ def test_bump_snapshot_specific_snapshot_metadata(self, db_request, monkeypatch)
647645 bump_s_calls = fake_metadata_repository .snapshot_bump_version .calls [0 ].kwargs
648646 bump_t_calls = fake_metadata_repository .timestamp_bump_version .calls [0 ].kwargs
649647
650- assert result == None
648+ assert result is None
651649 assert str (bump_s_calls ["snapshot_expires" ]) == "2019-06-17 09:05:01"
652650 assert bump_s_calls ["snapshot_metadata" ].signed .version == 2
653651 assert bump_s_calls ["store" ] is True
@@ -701,7 +699,7 @@ def test_bump_bin_n_roles(self, db_request, monkeypatch):
701699
702700 result = service .bump_bin_n_roles ()
703701
704- assert result == None
702+ assert result is None
705703 # PEP458 https://peps.python.org/pep-0458/#metadata-scalability
706704 assert len (fake_metadata_repository .bump_role_version .calls ) == 16384
707705 assert len (fake_metadata_repository .snapshot_update_meta .calls ) == 16384
@@ -747,15 +745,15 @@ def test_add_hashed_targets(self, db_request, monkeypatch):
747745 {
748746 "info" : {
749747 "hashes" : {"blake2b-256" : "dlskjflkdjflsdjfsdfdfsdfsdfs" },
750- "length" : 1024 ,
748+ "length" : 1025 ,
751749 "custom" : {"backsigned" : True },
752750 },
753751 "path" : "/sd/fa/dlskjflkdjflsdjfsdfdfsdfsdfs.packageyv1.tar.gz" ,
754752 },
755753 ]
756754 result = service .add_hashed_targets (targets )
757755
758- assert result == None
756+ assert result is None
759757 assert fake_metadata_repository .add_targets .calls == [
760758 pretend .call (
761759 {
0 commit comments