예제 #1
0
 public void testGetEncoding2() {
   String s =
       ""
           + "#test.py\n"
           + "# handles encoding and decoding of xmlBlaster socket protocol \n"
           + "\n"
           + "\n"
           + "";
   CharArrayReader reader = new CharArrayReader(s.toCharArray());
   String encoding = FileUtils.getPythonFileEncoding(reader, null);
   assertEquals(null, encoding);
 }
예제 #2
0
 public void testGetEncoding3() {
   // silent it in the tests
   FileUtils.LOG_ENCODING_ERROR = false;
   try {
     String s =
         ""
             + "#coding: foo_1\n"
             + // not valid encoding... will show in log but will not throw error
             "# handles encoding and decoding of xmlBlaster socket protocol \n"
             + "\n"
             + "\n"
             + "";
     CharArrayReader reader = new CharArrayReader(s.toCharArray());
     String encoding = FileUtils.getPythonFileEncoding(reader, null);
     assertEquals(null, encoding);
   } finally {
     FileUtils.LOG_ENCODING_ERROR = true;
   }
 }
예제 #3
0
 public void testGetEncoding() {
   String loc = TestDependent.TEST_PYSRC_LOC + "testenc/encutf8.py";
   String encoding = FileUtils.getPythonFileEncoding(new File(loc));
   assertEquals("UTF-8", encoding);
 }
예제 #4
0
 public void testGetEncoding10() {
   String s = "" + "#coding: latin1\n" + "\n" + "";
   CharArrayReader reader = new CharArrayReader(s.toCharArray());
   String encoding = FileUtils.getPythonFileEncoding(reader, null);
   assertEquals("latin1", encoding);
 }
예제 #5
0
 public void testGetEncoding5() {
   String s = "" + "#-*- coding: utf-8; -*-\n" + "\n" + "";
   CharArrayReader reader = new CharArrayReader(s.toCharArray());
   String encoding = FileUtils.getPythonFileEncoding(reader, null);
   assertEquals("utf-8", encoding);
 }