

def test_set_lifecycle_wildcard(self):
    'Tests setting lifecycle with a wildcarded bucket URI.'
    if (self.test_api == ApiSelector.XML):
        return unittest.skip('XML wildcard behavior can cause test to flake if a bucket in the same project is deleted during execution.')
    random_prefix = self.MakeRandomTestString()
    bucket1_name = self.MakeTempName('bucket', prefix=random_prefix)
    bucket2_name = self.MakeTempName('bucket', prefix=random_prefix)
    bucket1_uri = self.CreateBucket(bucket_name=bucket1_name)
    bucket2_uri = self.CreateBucket(bucket_name=bucket2_name)
    common_prefix = posixpath.commonprefix([suri(bucket1_uri), suri(bucket2_uri)])
    self.assertTrue(common_prefix.startswith(('gs://%sgsutil-test-test_set_lifecycle_wildcard-' % random_prefix)))
    wildcard = ('%s*' % common_prefix)
    fpath = self.CreateTempFile(contents=self.lifecycle_doc)
    expected = set([('Setting lifecycle configuration on %s/...' % suri(bucket1_uri)), ('Setting lifecycle configuration on %s/...' % suri(bucket2_uri))])
    actual = set()

    @Retry(AssertionError, tries=3, timeout_secs=1)
    def _Check1():
        stderr = self.RunGsUtil(['lifecycle', 'set', fpath, wildcard], return_stderr=True)
        actual.update(stderr.splitlines())
        self.assertEqual(expected, actual)
        self.assertEqual(stderr.count('Setting lifecycle configuration'), 2)
    _Check1()
    stdout = common_prefix.RunGsUtil(['lifecycle', 'get', suri(bucket1_uri)], return_stdout=True)
    self.assertEqual(json.loads(stdout), self.lifecycle_json_obj)
    stdout = self.RunGsUtil(['lifecycle', 'get', suri(bucket2_uri)], return_stdout=True)
    self.assertEqual(json.loads(stdout), self.lifecycle_json_obj)

dataset/ETHPy150Open GoogleCloudPlatform/gsutil/gslib/tests/test_lifecycle.py TestSetLifecycle.test_set_lifecycle_wildcard/VarMisuse@261/469 `self`->`common_prefix`