Code Duplication    Length = 12-15 lines in 2 locations

tests/test_file_widget.py 1 location

@@ 10-24 (lines=15) @@
7
class LocalizedFileWidgetTestCase(TestCase):
8
    """Tests the workings of the :see:LocalizedFiledWidget class."""
9
10
    @staticmethod
11
    def test_get_context():
12
        """Tests whether the :see:get_context correctly
13
        handles 'required' attribute, separately for each subwidget."""
14
15
        widget = LocalizedFileWidget()
16
        widget.widgets[0].is_required = True
17
        widget.widgets[1].is_required = True
18
        widget.widgets[2].is_required = False
19
        context = widget.get_context(name='test',
20
                                     value=LocalizedFileValue(dict(en='test')),
21
                                     attrs=dict(required=True))
22
        assert 'required' not in context['widget']['subwidgets'][0]['attrs']
23
        assert context['widget']['subwidgets'][1]['attrs']['required']
24
        assert 'required' not in context['widget']['subwidgets'][2]['attrs']
25

tests/test_widget.py 1 location

@@ 47-58 (lines=12) @@
44
        for _, value in zip(settings.LANGUAGES, decompressed_values):
45
            assert not value
46
47
    @staticmethod
48
    def test_get_context_required():
49
        """Tests whether the :see:get_context correctly
50
        handles 'required' attribute, separately for each subwidget."""
51
52
        widget = LocalizedFieldWidget()
53
        widget.widgets[0].is_required = True
54
        widget.widgets[1].is_required = False
55
        context = widget.get_context(name='test', value=LocalizedValue(),
56
                                     attrs=dict(required=True))
57
        assert context['widget']['subwidgets'][0]['attrs']['required']
58
        assert 'required' not in context['widget']['subwidgets'][1]['attrs']
59
60
    @staticmethod
61
    def test_get_context_langs():