def test_invalid_modes(self):
    'Test various invalid mode configurations.'
    INVALID_MODE_RA = 'Invalid mode: "ra"'
    INVALID_MODE_RT = 'Invalid mode: "rt"'
    INVALID_MODE_BR = 'Invalid mode: "br"'
    MN_DETECTION_ONLY = 'Magic number detection only when reading'
    self.assertRaisesRegex(ValueError, INVALID_MODE_RA, tools.open_archive, '/dev/null', 'ra')
    self.assertRaisesRegex(ValueError, INVALID_MODE_RT, tools.open_archive, '/dev/null', 'rt')
    self.assertRaisesRegex(ValueError, INVALID_MODE_BR, tools.open_archive, '/dev/null', 'br')
    self.assertRaisesRegex(ValueError, MN_DETECTION_ONLY, tools.open_archive, '/dev/null', 'wb', False)
Test various invalid mode configurations.
def test_invalid_modes(self):
    
    INVALID_MODE_RA = 'Invalid mode: "ra"'
    INVALID_MODE_RT = 'Invalid mode: "rt"'
    INVALID_MODE_BR = 'Invalid mode: "br"'
    MN_DETECTION_ONLY = 'Magic number detection only when reading'
    self.assertRaisesRegex(ValueError, INVALID_MODE_RA, tools.open_archive, '/dev/null', 'ra')
    self.assertRaisesRegex(ValueError, INVALID_MODE_RT, tools.open_archive, '/dev/null', 'rt')
    self.assertRaisesRegex(ValueError, INVALID_MODE_BR, tools.open_archive, '/dev/null', 'br')
    self.assertRaisesRegex(ValueError, MN_DETECTION_ONLY, tools.open_archive, '/dev/null', 'wb', False)