Passed
Push — master ( 5347db...d5f43c )
by Swen
02:49 queued 01:20
created

LocalizedFileWidgetTestCase.test_get_context()   A

Complexity

Conditions 4

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 15
loc 15
rs 9.2
cc 4
1
from django.test import TestCase
0 ignored issues
show
Configuration introduced by
The import django.test could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
2
3
from localized_fields.value import LocalizedFileValue
4
from localized_fields.widgets import LocalizedFileWidget
5
6
7
class LocalizedFileWidgetTestCase(TestCase):
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
8
    """Tests the workings of the :see:LocalizedFiledWidget class."""
9
10 View Code Duplication
    @staticmethod
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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
0 ignored issues
show
Bug introduced by
The Instance of LocalizedFileWidget does not seem to have a member named widgets.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
17
        widget.widgets[1].is_required = True
0 ignored issues
show
Bug introduced by
The Instance of LocalizedFileWidget does not seem to have a member named widgets.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
18
        widget.widgets[2].is_required = False
0 ignored issues
show
Bug introduced by
The Instance of LocalizedFileWidget does not seem to have a member named widgets.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
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