File tree Expand file tree Collapse file tree 1 file changed +25
-6
lines changed
Expand file tree Collapse file tree 1 file changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -1260,14 +1260,33 @@ def test_valid_full_validate(self):
12601260 )
12611261
12621262 def test_failed_create_bag (self ):
1263- # assert exit code 1
1264- # assert failure message
1265- return False
1263+ os .chmod (self .tmpdir , 0 )
1264+
1265+ testargs = ["bagit.py" , self .tmpdir ]
1266+
1267+ with self .assertLogs () as captured :
1268+ with self .assertRaises (SystemExit ) as cm :
1269+ with mock .patch .object (sys , 'argv' , testargs ):
1270+ bagit .main ()
1271+
1272+ self .assertEqual (cm .exception .code , 1 )
1273+ self .assertIn (
1274+ "Failed to create bag in %s" % self .tmpdir ,
1275+ captured .records [- 1 ].getMessage ()
1276+ )
12661277
12671278 def test_create_bag (self ):
1268- # assert exit code 0
1269- # assert creation message
1270- return False
1279+ testargs = ["bagit.py" , self .tmpdir ]
1280+
1281+ with self .assertLogs () as captured :
1282+ with self .assertRaises (SystemExit ) as cm :
1283+ with mock .patch .object (sys , 'argv' , testargs ):
1284+ bagit .main ()
1285+
1286+ for rec in captured .records :
1287+ print (rec .getMessage ())
1288+
1289+ self .assertEqual (cm .exception .code , 0 )
12711290
12721291
12731292class TestUtils (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments