Tests - Migrate bug.1006.t to python

This commit is contained in:
Renato Alves 2015-02-16 03:22:44 +00:00
parent 4b839f2c83
commit e831f85823

View file

@ -1,4 +1,5 @@
#! /usr/bin/env perl #!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
################################################################################ ################################################################################
## ##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. ## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
@ -25,46 +26,63 @@
## ##
################################################################################ ################################################################################
use strict; import sys
use warnings; import os
use Test::More tests => 4; import unittest
from datetime import datetime
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Ensure environment has no influence. from basetest import Task, TestCase, Taskd, ServerTestCase
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Create the rc file. class TestBug1006(TestCase):
if (open my $fh, '>', $rc) """Bug with completion of "des" in task descriptions and annotations. It
{ happens for all the shortcuts for column attributes that are automatically
print $fh "data.location=.\n", completed. This is because DOM elements are checked before standard words
"verbose=affected\n"; when strings are tokenized.
close $fh; """
} def setUp(self):
self.t = Task()
self.t.config("verbose", "affected")
# Bug with completion of "des" in task descriptions and annotations. It happens def initial_tasks(self):
# for all the shortcuts for column attributes that are automatically completed. self.t(("add", "des"))
# This is because DOM elements are checked before standard words when strings self.t(("1", "annotate", "des"))
# are tokenized.
# Check that the completion is inactive in task descriptions def test_completion_of_des_inactive(self):
qx{../src/task rc:$rc add des 2>&1}; "Check that the completion is inactive in task descriptions"
qx{../src/task rc:$rc 1 annotate des 2>&1};
my $output = qx{../src/task rc:$rc 1 info 2>&1};
like ($output, qr/^Description\s+des$/ms, "$ut: Attribute not completed in description");
unlike ($output, qr/description/ms, "$ut: Attribute not completed in description");
# Check that the completion works when needed self.initial_tasks()
$output = qx{../src/task rc:$rc des:des 2>&1}; code, out, err = self.t(("1", "info"))
like ($output, qr/^1 task$/ms, "$ut: Task found using its description");
qx{../src/task rc:$rc add entrée interdite 2>&1}; expected = "Description +des\n"
$output = qx{../src/task rc:$rc list interdite 2>&1}; errormsg = "Attribute not completed in description"
like ($output, qr/entrée interdite/, "$ut: 'entrée' left intact"); self.assertRegexpMatches(out, expected, msg=errormsg)
# Cleanup. notexpected = "description"
unlink qw(pending.data completed.data undo.data backlog.data), $rc; self.assertNotIn(notexpected, out, msg=errormsg)
exit 0;
def test_completion_as_expected(self):
"Check that the completion works when needed"
self.initial_tasks()
code, out, err = self.t(("des:des",))
errormsg = "Task found using its description"
self.assertIn("1 task", out, msg=errormsg)
def test_accented_chars(self):
"Check that é in entrée remains untouched"
self.t(("add", "entrée interdite"))
code, out, err = self.t(("list", "interdite"))
errormsg = "'entrée' left intact"
self.assertIn("entrée interdite", out, msg=errormsg)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4