Passed
Push — master ( 596012...87da33 )
by Fernando
01:30
created

tests.data.test_subject   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TestSubject.test_positional_args() 0 4 3
A TestSubject.test_input_dict() 0 5 2
A TestSubject.test_no_sample() 0 6 3
1
#!/usr/bin/env python
2
3
"""Tests for Subject."""
4
5
import tempfile
6
from torchio import INTENSITY, Subject, Image, RandomFlip
7
from ..utils import TorchioTestCase
8
9
10
class TestSubject(TorchioTestCase):
11
    """Tests for `Subject`."""
12
    def test_positional_args(self):
13
        with self.assertRaises(ValueError):
14
            with tempfile.NamedTemporaryFile() as f:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "f" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
15
                Subject(Image(f.name, INTENSITY))
16
17
    def test_input_dict(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...
18
        with tempfile.NamedTemporaryFile() as f:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "f" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
19
            input_dict = {'image': Image(f.name, INTENSITY)}
20
            Subject(input_dict)
21
            Subject(**input_dict)
22
23
    def test_no_sample(self):
24
        with tempfile.NamedTemporaryFile() as f:
0 ignored issues
show
Coding Style Naming introduced by
Variable name "f" doesn't conform to snake_case naming style ('(([a-z_][a-z0-9_]2,)|(_[a-z0-9_]*)|(__[a-z][a-z0-9_]+__))$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
25
            input_dict = {'image': Image(f.name, INTENSITY)}
26
            subject = Subject(input_dict)
27
            with self.assertRaises(RuntimeError):
28
                RandomFlip()(subject)
29