From d1059df1494d1aea273676c127a02c2498916b87 Mon Sep 17 00:00:00 2001 From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch> Date: Wed, 12 Dec 2018 15:36:55 +0100 Subject: [PATCH] Pytest tests for pathtools.parse_path --- tests/test_pathtools.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_pathtools.py diff --git a/tests/test_pathtools.py b/tests/test_pathtools.py new file mode 100644 index 0000000..07c6813 --- /dev/null +++ b/tests/test_pathtools.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import pytest +from imcflibs.pathtools import parse_path + +__author__ = "Niko Ehrenfeuchter" +__copyright__ = "Niko Ehrenfeuchter" +__license__ = "gpl3" + + +def test_parse_path(): + path = '/tmp/foo/' + path_to_dir = parse_path(path) + path_to_file = parse_path(path + 'file.ext') + path_to_file_noext = parse_path(path + 'file') + + assert path_to_file['orig'] == path + 'file.ext' + assert path_to_file['path'] == path + assert path_to_file['dname'] == 'foo' + assert path_to_file['fname'] == 'file.ext' + assert path_to_file['ext'] == '.ext' + + assert path_to_file_noext['ext'] == '' + assert path_to_file_noext['fname'] == 'file' + assert path_to_file_noext['dname'] == 'foo' + assert path_to_file_noext['path'] == path + + assert path_to_dir['path'] == path + assert path_to_dir['fname'] == '' + assert path_to_dir['dname'] == 'foo' + assert path_to_dir['ext'] == '' + -- GitLab