the solution was much easier than I thought.
The test client
object has a method set_cookie
, so the code should simply be:
with app.test_client() as c:
with c.session_transaction() as sess:
sess['user_id'] = 'myuserid'
sess['_fresh'] = True
c.set_cookie('localhost', 'MYCOOKIE', 'cookie_value')
resp = c.get('/someurl')