Passed
Push — master ( f7c14f...06873a )
by Swen
02:26
created

LocalizedFileFieldFormTestCase   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 9
c 2
b 0
f 1
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B test_clean() 0 17 5
A test_bound_data() 0 11 4
1
from django.conf import settings
0 ignored issues
show
Configuration introduced by
The import django.conf 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
from django.core.exceptions import ValidationError
0 ignored issues
show
Configuration introduced by
The import django.core.exceptions 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...
3
from django.forms.widgets import FILE_INPUT_CONTRADICTION
0 ignored issues
show
Configuration introduced by
The import django.forms.widgets 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...
4
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...
5
6
from localized_fields.forms import LocalizedFileFieldForm
7
8
9
class LocalizedFileFieldFormTestCase(TestCase):
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
10
    """Tests the workings of the :see:LocalizedFileFieldForm class."""
11
12
    def test_clean(self):
13
        """Tests whether the :see:clean function is working properly."""
14
15
        formfield = LocalizedFileFieldForm(required=True)
16
        with self.assertRaises(ValidationError):
0 ignored issues
show
Bug introduced by
The Instance of LocalizedFileFieldFormTestCase does not seem to have a member named assertRaises.

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
            formfield.clean([])
18
        with self.assertRaises(ValidationError):
0 ignored issues
show
Bug introduced by
The Instance of LocalizedFileFieldFormTestCase does not seem to have a member named assertRaises.

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
            formfield.clean([], {'en': None})
20
        with self.assertRaises(ValidationError):
0 ignored issues
show
Bug introduced by
The Instance of LocalizedFileFieldFormTestCase does not seem to have a member named assertRaises.

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...
21
            formfield.clean("badvalue")
22
        with self.assertRaises(ValidationError):
0 ignored issues
show
Bug introduced by
The Instance of LocalizedFileFieldFormTestCase does not seem to have a member named assertRaises.

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...
23
            value = [FILE_INPUT_CONTRADICTION] * len(settings.LANGUAGES)
24
            formfield.clean(value)
25
26
        formfield = LocalizedFileFieldForm(required=False)
27
        formfield.clean([''] * len(settings.LANGUAGES))
28
        formfield.clean(['', ''], ['', ''])
29
30
    def test_bound_data(self):
0 ignored issues
show
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
31
        """Tests whether the :see:bound_data function is returns correctly 
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
32
        value"""
33
34
        formfield = LocalizedFileFieldForm()
35
        assert formfield.bound_data([''], None) == ['']
36
37
        initial = dict([(lang, '') for lang, _ in settings.LANGUAGES])
38
        value = [None] * len(settings.LANGUAGES)
39
        expected_value = [''] * len(settings.LANGUAGES)
40
        assert formfield.bound_data(value, initial) == expected_value
41
42