Test: Converted to Python

- Renamed utf8_tw.t to unicode.t, converted to Python, and added new feature
  testing.
This commit is contained in:
Paul Beckingham 2015-07-11 07:47:46 -04:00
parent 58d6d8be14
commit 18412822fd
2 changed files with 95 additions and 77 deletions

95
test/unicode.t Executable file
View file

@ -0,0 +1,95 @@
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# http://www.opensource.org/licenses/mit-license.php
#
###############################################################################
import sys
import os
import unittest
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from basetest import Task, TestCase
class TestUnicode(TestCase):
def setUp(self):
"""Executed before each test in the class"""
self.t = Task()
def test_direct_utf8(self):
"""Verify that UTF8 can be directly entered"""
self.t("add Çirçös")
self.t("add Hello world ☺")
self.t("add ¥£€¢₡₢₣₤₥₦₧₨₩₪₫₭₮₯ ")
self.t("add Pchnąć w tę łódź jeża lub ośm skrzyń fig")
self.t("add ๏ เป็นมนุษย์สุดประเสริฐเลิศคุณค่า")
self.t("add イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラムイ ロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム")
self.t("add いろはにほへとちりぬるを")
self.t("add D\\'fhuascail Íosa, Úrmhac na hÓighe Beannaithe, pór Éava agus Ádhaimh")
self.t("add Árvíztűrő tükörfúrógép")
self.t("add Kæmi ný öxi hér ykist þjófum nú bæði víl og ádrepa")
self.t("add Sævör grét áðan því úlpan var ónýt")
self.t("add Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Wolther spillede på xylofon.")
self.t("add Falsches Üben von Xylophonmusik quält jeden größeren Zwerg")
self.t("add Zwölf Boxkämpfer jagten Eva quer über den Sylter Deich")
self.t("add Heizölrückstoßabdämpfung")
self.t("add Γαζέες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο")
self.t("add Ξεσκεπάζω τὴν ψυχοφθόρα βδελυγμία")
# 17 tasks means none of the above failed.
code, out, err = self.t("ls")
self.assertIn("17", out)
def test_utf8_project(self):
"""Verify that UTF8 can be used in a project name"""
self.t("add project:Çirçös utf8 in project")
code, out, err = self.t("_get 1.project")
self.assertEqual("Çirçös\n", out)
def test_utf8_tag(self):
"""Verify that UTF8 can be used in a tag"""
self.t("add utf8 in tag +Zwölf");
code, out, err = self.t("_get 1.tags")
self.assertEqual("Zwölf\n", out);
def test_unicode_escape1(self):
"""Verify U+NNNN unicode sequences"""
self.t("add Price U+20AC4")
code, out, err = self.t("_get 1.description")
self.assertEqual("Price €4\n", out);
def test_unicode_escape2(self):
"""Verify \\uNNNN unicode sequences"""
self.t("add Price \\u20A43")
code, out, err = self.t("_get 1.description")
self.assertEqual("Price ₤3\n", out);
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -1,77 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 3;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'utf8.rc')
{
print $fh "data.location=.\n";
close $fh;
}
# Add a task with UTF8 in the description.
qx{../src/task rc:utf8.rc add Çirçös 2>&1};
qx{../src/task rc:utf8.rc add Hello world ☺ 2>&1};
qx{../src/task rc:utf8.rc add ¥£€¢₡₢₣₤₥₦₧₨₩₪₫₭₮₯ 2>&1};
qx{../src/task rc:utf8.rc add Pchnąć w tę łódź jeża lub ośm skrzyń fig 2>&1};
qx{../src/task rc:utf8.rc add ๏ เป็นมนุษย์สุดประเสริฐเลิศคุณค่า 2>&1};
qx{../src/task rc:utf8.rc add イロハニホヘト チリヌルヲ ワカヨタレソ ツネナラムイ ロハニホヘト チリヌルヲ ワカヨタレソ ツネナラム 2>&1};
qx{../src/task rc:utf8.rc add いろはにほへとちりぬるを 2>&1};
qx{../src/task rc:utf8.rc add D\\'fhuascail Íosa, Úrmhac na hÓighe Beannaithe, pór Éava agus Ádhaimh 2>&1};
qx{../src/task rc:utf8.rc add Árvíztűrő tükörfúrógép 2>&1};
qx{../src/task rc:utf8.rc add Kæmi ný öxi hér ykist þjófum nú bæði víl og ádrepa 2>&1};
qx{../src/task rc:utf8.rc add Sævör grét áðan því úlpan var ónýt 2>&1};
qx{../src/task rc:utf8.rc add Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Wolther spillede på xylofon. 2>&1};
qx{../src/task rc:utf8.rc add Falsches Üben von Xylophonmusik quält jeden größeren Zwerg 2>&1};
qx{../src/task rc:utf8.rc add Zwölf Boxkämpfer jagten Eva quer über den Sylter Deich 2>&1};
qx{../src/task rc:utf8.rc add Heizölrückstoßabdämpfung 2>&1};
qx{../src/task rc:utf8.rc add Γαζέες καὶ μυρτιὲς δὲν θὰ βρῶ πιὰ στὸ χρυσαφὶ ξέφωτο 2>&1};
qx{../src/task rc:utf8.rc add Ξεσκεπάζω τὴν ψυχοφθόρα βδελυγμία 2>&1};
my $output = qx{../src/task rc:utf8.rc ls 2>&1};
diag ($output);
like ($output, qr/17/, 'all 17 tasks shown');
qx{../src/task rc:utf8.rc add project:Çirçös utf8 in project 2>&1};
$output = qx{../src/task rc:utf8.rc ls project:Çirçös 2>&1};
like ($output, qr/Çirçös.+utf8 in project/, 'utf8 in project works');
qx{../src/task rc:utf8.rc add utf8 in tag +Zwölf 2>&1};
$output = qx{../src/task rc:utf8.rc ls +Zwölf 2>&1};
like ($output, qr/utf8 in tag/, 'utf8 in tag works');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data utf8.rc);
exit 0;