This module changes the I/O layers of STDOUT and STDERR to encode to UTF-8,
so it will double encode when using test libraries like Test::Mojo. You
should not use them together.

On Mon, Dec 12, 2016 at 9:18 AM, Daniel Mantovani <[email protected]> wrote:

> When testing Mojo apps, many times you need to use both Test::Mojo and
> Test::More. In those cases, I found difficult to print utf8 coded strings
> as test messages.
>
> See this example:
>
> $ cat with_More-UTF8.t
>
> use Test::More tests => 3;
> use utf8;
> use Test::More::UTF8;
> use Test::Mojo;
>
> use Mojolicious::Lite;
> get '/' => sub {shift->render(text => '')};
> app->start;
>
> my $t = Test::Mojo->new();
> $t->get_ok('/')
>   ->status_is(200, 'Test::Mojo dice: ¡Buenos días!');
> is 1,1,'Test::More responde: ¡Buenos días!';
>
> Then if I run the test, it passes, but take a look on the  message from
> Test::Mojo:
>
> $ prove -v with_More-UTF8.t
> with_More-UTF8.t ..
> 1..3
> [Mon Dec 12 10:49:34 2016] [debug] GET "/"
> [Mon Dec 12 10:49:34 2016] [debug] Routing to a callback
> [Mon Dec 12 10:49:34 2016] [debug] 200 OK (0.000515s, 1941.748/s)
> ok 1 - GET /
> ok 2 - Test::Mojo dice: ¡Buenos días!
> ok 3 - Test::More responde: ¡Buenos días!
> ok
> All tests successful.
> Files=1, Tests=3,  0 wallclock secs ( 0.01 usr  0.01 sys +  0.22 cusr
>  0.01 csys =  0.25 CPU)
> Result: PASS
>
> Now if I comment out the Test::More::UTF8 module,
>
> $ cat without_More-UTF8.t
>
> use Test::More tests => 3;
> use utf8;
> #use Test::More::UTF8;
> use Test::Mojo;
>
> use Mojolicious::Lite;
> get '/' => sub {shift->render(text => '')};
> app->start;
>
> my $t = Test::Mojo->new();
> $t->get_ok('/')
>   ->status_is(200, 'Test::Mojo dice: ¡Buenos días!');
> is 1,1,'Test::More responde: ¡Buenos días!';
>
> Now if I run this test, it also passes, but the problem now is in
> Test::More part (this is actually normal behavior for Test::More module,
> because it doesn't support utf8 without including Test::More::UTF8)
>
> $ prove -v without_More-UTF8.t
> without_More-UTF8.t ..
> 1..3
> [Mon Dec 12 10:50:12 2016] [debug] GET "/"
> [Mon Dec 12 10:50:12 2016] [debug] Routing to a callback
> [Mon Dec 12 10:50:12 2016] [debug] 200 OK (0.000503s, 1988.072/s)
> ok 1 - GET /
> ok 2 - Test::Mojo dice: ¡Buenos días!
> ok 3 - Test::More responde: �Buenos d�as!
> ok
> All tests successful.
> Files=1, Tests=3,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.23 cusr
>  0.00 csys =  0.25 CPU)
> Result: PASS
> $
>
>
> It seems like if using Test::More::UTF8 breaks something internally in
> Test::Mojo
> Do you know of any workaround this problem?
> Thanks,
> Daniel
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to