mmcv/tests/test_visualization.py
Kai Chen eae81c1e86
Add yapf and isort to travis (#96)
* add yapf and isort to travis

* minor formatting

* remove blank lines

* skip unit tests for progressbar when python2

* update travis to ubuntu 16.04

* use a newer version ffmpeg

* add -y to add-apt-repository
2019-07-30 23:15:56 +08:00

19 lines
554 B
Python

import numpy as np
import pytest
import mmcv
def test_color():
assert mmcv.color_val(mmcv.Color.blue) == (255, 0, 0)
assert mmcv.color_val('green') == (0, 255, 0)
assert mmcv.color_val((1, 2, 3)) == (1, 2, 3)
assert mmcv.color_val(100) == (100, 100, 100)
assert mmcv.color_val(np.zeros(3, dtype=np.int)) == (0, 0, 0)
with pytest.raises(TypeError):
mmcv.color_val([255, 255, 255])
with pytest.raises(TypeError):
mmcv.color_val(1.0)
with pytest.raises(AssertionError):
mmcv.color_val((0, 0, 500))