File: test_api.py

package info (click to toggle)
keras-preprocessing 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 400 kB
  • sloc: python: 4,161; makefile: 11; sh: 10
file content (32 lines) | stat: -rw-r--r-- 1,003 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pytest

import keras_preprocessing


def test_api_modules():
    expected_exposed_modules = [
        'image',
        'sequence',
        'text'
    ]
    for _module in expected_exposed_modules:
        assert hasattr(keras_preprocessing, _module)


def test_get_keras_submodule(monkeypatch):
    monkeypatch.setattr(keras_preprocessing, '_KERAS_BACKEND', 'backend')
    assert 'backend' == keras_preprocessing.get_keras_submodule('backend')
    monkeypatch.setattr(keras_preprocessing, '_KERAS_UTILS', 'utils')
    assert 'utils' == keras_preprocessing.get_keras_submodule('utils')


def test_get_keras_submodule_errors(monkeypatch):
    with pytest.raises(ImportError):
        keras_preprocessing.get_keras_submodule('something')

    monkeypatch.setattr(keras_preprocessing, '_KERAS_BACKEND', None)
    with pytest.raises(ImportError):
        keras_preprocessing.get_keras_submodule('backend')

    with pytest.raises(ImportError):
        keras_preprocessing.get_keras_submodule('utils')