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); }
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; } }
public void testGetEncoding() { String loc = TestDependent.TEST_PYSRC_LOC + "testenc/encutf8.py"; String encoding = FileUtils.getPythonFileEncoding(new File(loc)); assertEquals("UTF-8", encoding); }
public void testGetEncoding10() { String s = "" + "#coding: latin1\n" + "\n" + ""; CharArrayReader reader = new CharArrayReader(s.toCharArray()); String encoding = FileUtils.getPythonFileEncoding(reader, null); assertEquals("latin1", encoding); }
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); }