def gen_objects(elems):
____import random,string
____name_pattern = ["name","n-ame","n-a-me","n-a-m-e"]
____weight_pattern = ["100g","1kg","1.5kg"]
____temp = []
____for i in range(elems):
________rand_strings = "".join([random.choice(string.punctuation + string.ascii_letters + string.digits) for i in range(random.randint(4,7))])
________rand_name = random.choice(name_pattern)
________rand_weight = random.choice(weight_pattern)
________rand_footer_num = random.randint(10,99)
________n_w = f"{rand_strings}/im-{rand_name}-{rand_weight}/{rand_footer_num}{rand_strings}"
________w_n = f"{rand_strings}/im-{rand_weight}-{rand_name}/{rand_footer_num}{rand_strings}"
________w_n_w = f"{rand_strings}/im-{rand_weight}-{rand_name}-{rand_weight}/{rand_footer_num}{rand_strings}"
________obj = random.choice([n_w,w_n,w_n_w])
________temp.append(obj)
____return temp

testlist = gen_objects(10)

こういう感じのテストユニットをループで回して正規表現でnameを抽出していってnamelistを作成しようとしています