Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Commit

Permalink
Various fixes and updates. (#1450)
Browse files Browse the repository at this point in the history
* Various fixes and updates.

- Add ability to run disabled tests from make.cmd and show in results whether test is normally disabled.
- Fixes for _csv module (all tests passing)
- Enable test_csv

* Fixes based on feedback
  • Loading branch information
slide committed Oct 2, 2016
1 parent 35f1106 commit 9caf00d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 26 deletions.
Expand Up @@ -940,11 +940,12 @@ class mydialect(csv.Dialect):
self.assertEqual(str(cm.exception),
'"delimiter" must be an 1-character string')

mydialect.delimiter = u","
with self.assertRaises(csv.Error) as cm:
mydialect()
self.assertEqual(str(cm.exception),
'"delimiter" must be string, not unicode')
if sys.platform != 'cli':
mydialect.delimiter = u","
with self.assertRaises(csv.Error) as cm:
mydialect()
self.assertEqual(str(cm.exception),
'"delimiter" must be string, not unicode')

mydialect.delimiter = 4
with self.assertRaises(csv.Error) as cm:
Expand Down Expand Up @@ -1163,16 +1164,16 @@ def test_write(self):
## class TestUnicode(unittest.TestCase):
## def test_unicode_read(self):
## import codecs
## f = codecs.EncodedFile(StringIO("Martin von Löwis,"
## "Marc André Lemburg,"
## f = codecs.EncodedFile(StringIO("Martin von Löwis,"
## "Marc André Lemburg,"
## "Guido van Rossum,"
## "François Pinard\r\n"),
## "François Pinard\r\n"),
## data_encoding='iso-8859-1')
## reader = csv.reader(f)
## self.assertEqual(list(reader), [[u"Martin von Löwis",
## u"Marc André Lemburg",
## self.assertEqual(list(reader), [[u"Martin von Löwis",
## u"Marc André Lemburg",
## u"Guido van Rossum",
## u"François Pinardn"]])
## u"François Pinardn"]])

def test_main():
mod = sys.modules[__name__]
Expand Down
25 changes: 17 additions & 8 deletions Languages/IronPython/IronPython.Modules/_csv.cs
Expand Up @@ -438,7 +438,7 @@ static string SetChar(string name, object src, bool found, string @default)
else if (source.Length != 1)
{
throw PythonOps.TypeError(
"\"{0}\" must be a 1-character string",
"\"{0}\" must be an 1-character string",
name);
}
else
Expand All @@ -447,7 +447,7 @@ static string SetChar(string name, object src, bool found, string @default)
else
{
throw PythonOps.TypeError(
"\"{0}\" must be a 1-character string", name);
"\"{0}\" must be string, not {1}", name, PythonOps.GetPythonTypeName(src));
}
}
return result;
Expand All @@ -463,7 +463,7 @@ static string SetString(string name, object src, bool found, string @default)
else if (!(src is string))
{
throw PythonOps.TypeError(
"\"{0}\" must be an string", name);
"\"{0}\" must be a string", name);
}
else
{
Expand Down Expand Up @@ -560,7 +560,7 @@ static string SetString(string name, object src, bool found, string @default)
if (_quoting < QUOTE_MINIMAL || _quoting > QUOTE_NONE)
throw PythonOps.TypeError("bad \"quoting\" value");
if (string.IsNullOrEmpty(_delimiter))
throw PythonOps.TypeError("delimiter must be set");
throw PythonOps.TypeError("\"delimiter\" must be an 1-character string");

if ((foundParams["quotechar"] && quotechar == null) && quoting == null)
_quoting = QUOTE_NONE;
Expand Down Expand Up @@ -693,8 +693,15 @@ public bool MoveNext()
object lineobj = null;
if (!_iterator.MoveNext())
{
if (_field.Length != 0)
throw MakeError("newline inside string");
// End of input OR exception
if(_field.Length > 0 || _state == State.InQuotedField) {
if(_reader._dialect.strict) {
throw MakeError("unexpected end of data");
} else {
ParseSaveField();
return true;
}
}
return false;
}
else
Expand Down Expand Up @@ -732,6 +739,8 @@ public bool MoveNext()

} while (_state != State.StartRecord);



return result;
}

Expand Down Expand Up @@ -1067,12 +1076,12 @@ public void writerow(CodeContext/*!*/ context, object sequence)
JoinAppend((string)field, quoted, rowlen == 1);
else if (field is double)
{
JoinAppend(DoubleOps.__str__(context, (double)field),
JoinAppend(DoubleOps.__repr__(context, (double)field),
quoted, rowlen == 1);
}
else if (field is float)
{
JoinAppend(SingleOps.__str__(context, (float)field),
JoinAppend(SingleOps.__repr__(context, (float)field),
quoted, rowlen == 1);
}
else if (field == null)
Expand Down
2 changes: 1 addition & 1 deletion Test/IronPython.tests
Expand Up @@ -2322,7 +2322,7 @@
<Arguments>test\test_csv.py</Arguments>
<MaxDuration>600000</MaxDuration>
<LongRunning>false</LongRunning>
<Disabled>true</Disabled> <!-- FAILED -->
<Disabled>false</Disabled>
<RequiresAdmin>false</RequiresAdmin>
<NotParallelSafe>false</NotParallelSafe>
<WorkingDirectory>%DLR_ROOT%\External.LCA_RESTRICTED\Languages\IronPython\27\Lib</WorkingDirectory>
Expand Down
12 changes: 6 additions & 6 deletions Test/TestRunner/TestRunner/Program.cs
Expand Up @@ -212,7 +212,7 @@ class Program {
private void RunTestForConsole(Test test) {
lock (this) {
if (!_quiet && _verbose) {
Console.Write("{0,-100}", test.Category.Name + " " + test.Name);
Console.Write("{0,-80}", test.Category.Name + " " + test.Name);
}
}

Expand All @@ -226,24 +226,24 @@ class Program {
lock (this) {
if (!_quiet) {
if (_verbose) {
const string resultFormat = "{0,-10}";
const string resultFormat = "{0,-25}";
var originalColor = Console.ForegroundColor;
switch (result.Status) {
case TestResultStatus.Skipped:
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write(resultFormat, "SKIPPED");
Console.Write(resultFormat, test.Disabled && _runDisabled ? "SKIPPED (DISABLED)" : "SKIPPED");
break;
case TestResultStatus.TimedOut:
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(resultFormat, "TIMEOUT");
Console.Write(resultFormat, test.Disabled && _runDisabled ? "TIMEOUT (DISABLED)" : "TIMEOUT");
break;
case TestResultStatus.Passed:
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(resultFormat, "PASSED");
Console.Write(resultFormat, test.Disabled && _runDisabled ? "PASSED (DISABLED)" : "PASSED");
break;
case TestResultStatus.Failed:
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(resultFormat, "FAILED");
Console.Write(resultFormat, test.Disabled && _runDisabled ? "FAILED (DISABLED)" : "FAILED");
break;
case TestResultStatus.Disabled:
Console.ForegroundColor = ConsoleColor.Blue;
Expand Down
4 changes: 4 additions & 0 deletions make.cmd
Expand Up @@ -64,6 +64,10 @@ goto :exit
Test\test-ipy-tc.cmd /all /runlong
goto :exit

:testalldisabled
Test\test-ipy-tc.cmd /all /runlong /rundisabled
goto :exit

:distclean
msbuild /t:DistClean /p:BaseConfiguration=Release /verbosity:minimal /nologo
msbuild /t:DistClean /p:BaseConfiguration=Debug /verbosity:minimal /nologo
Expand Down

0 comments on commit 9caf00d

Please sign in to comment.