From 44652d49fbf1a66445d9ade04deb75463d199c38 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 12 Jul 2019 04:39:48 -0400 Subject: [PATCH] Add test utility to return an id_list Makes creating an id_list for testing from a list test instances easier. Signed-off-by: Roberto Rosario --- mayan/apps/common/tests/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mayan/apps/common/tests/utils.py b/mayan/apps/common/tests/utils.py index 85daf0c524..5b7aac4993 100644 --- a/mayan/apps/common/tests/utils.py +++ b/mayan/apps/common/tests/utils.py @@ -1,6 +1,10 @@ +from __future__ import absolute_import, unicode_literals + from contextlib import contextmanager import sys +from django.utils.encoding import force_text + class NullFile(object): def write(self, string): @@ -13,3 +17,9 @@ def mute_stdout(): sys.stdout = NullFile() yield sys.stdout = stdout_old + + +def as_id_list(items): + return ','.join( + [force_text(item.pk) for item in items] + )