3

I have a url dictionary and tuple:

url = {'url': 'https://test.com'}
expected = (0, "Test")

I need to zip the two objects together into 1 tuple so I can pass it into pytest parametrize as:

({'url': 'https://test.com'}, 0, "Test")

However my output when I try using zip(url, expected) is giving me strange outputs like:

('url', 0)

Can someone advise how I can do this? I've tried using zip(url, *expected) as well but that did not work either. Thank you

Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
staten12
  • 735
  • 3
  • 9
  • 20

1 Answers1

5
>>> (url, ) + expected
({'url': 'https://test.com'}, 0, 'Test')
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • Thanks! will this work with zipping a list of single elements and list of tuples as well? For example turning 2 urls and 2 tuples into [(url, 0, "Test'), (url2, 1, "Test")] – staten12 May 14 '18 at 15:35
  • `[(url, ) + expect for url, expect in zip(urls, expected)]` works using your provided answer. Thanks again – staten12 May 14 '18 at 16:01