是否有任何方法可以在表格视图中增加或减少单元格的高度,具体取决于其中标签的文本?
答案 0 :(得分:0)
在这里,您可以根据文本的长度获得标签的高度(动态):
from werkzeug.test import EnvironBuilder
from django.test import TestCase
from example_app.utils import print_tls_found_by_django_tls
class TestUtils(TestCase):
def setUp(self):
self.build_tls_request()
def test_print_tls_found_by_django_tls(self):
print_tls_found_by_django_tls()
def build_tls_request(self):
return EnvironBuilder(method='GET').get_request()
然后你可以设置tableview的高度:
(venv) vladir@vladir:~/work/project_example_all/example/example_app$ coverage run ./manage.py test example_app.tests.TestUtils.test_print_tls_found_by_django_tls
Creating test database for alias 'default'...
E
======================================================================
ERROR: test_print_tls_found_by_django_tls (affiliate_tracking.tests.test_utils.TestUtils)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/vladir/work/project_example_all/example/venv/lib/python3.5/site-packages/werkzeug/local.py", line 70, in __getattr__
return self.__storage__[self.__ident_func__()][name]
KeyError: 140239354230528
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vladir/work/project_example_all/example/venv/lib/python3.5/site-packages/werkzeug/local.py", line 308, in _get_current_object
return getattr(self.__local, self.__name__)
File "/home/vladir/work/project_example_all/example/venv/lib/python3.5/site-packages/werkzeug/local.py", line 72, in __getattr__
raise AttributeError(name)
AttributeError: request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/vladir/work/project_example_all/example/example_app/affiliate_tracking/tests/test_utils.py", line 15, in test_print_tls_found_by_django_tls
print_tls_found_by_django_tls()
File "/home/vladir/work/project_example_all/example/example_app/affiliate_tracking/utils.py", line 67, in print_tls_found_by_django_tls
print(request)
File "/home/vladir/work/project_example_all/example/venv/lib/python3.5/site-packages/werkzeug/local.py", line 366, in <lambda>
__str__ = lambda x: str(x._get_current_object())
File "/home/vladir/work/project_example_all/example/venv/lib/python3.5/site-packages/werkzeug/local.py", line 310, in _get_current_object
raise RuntimeError('no object bound to %s' % self.__name__)
RuntimeError: no object bound to request
----------------------------------------------------------------------
Ran 1 test in 0.002s
FAILED (errors=1)
Destroying test database for alias 'default'...