本文整理汇总了Python中wakatime.compat.u函数的典型用法代码示例。如果您正苦于以下问题:Python u函数的具体用法?Python u怎么用?Python u使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了u函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_invalid_proxy
def test_invalid_proxy(self, logs):
logging.disable(logging.NOTSET)
response = CustomResponse()
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with utils.TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/emptyfile.txt'
shutil.copy(entity, os.path.join(tempdir, 'emptyfile.txt'))
entity = os.path.realpath(os.path.join(tempdir, 'emptyfile.txt'))
proxy = 'invaliddd:proxyarg'
config = 'tests/samples/configs/good_config.cfg'
args = ['--file', entity, '--config', config, '--proxy', proxy]
with self.assertRaises(SystemExit) as e:
execute(args)
self.assertEquals(int(str(e.exception)), 2)
self.assertEquals(sys.stdout.getvalue(), '')
expected = 'error: Invalid proxy. Must be in format https://user:[email protected]:port or socks5://user:[email protected]:port or domain\\user:pass.'
self.assertIn(expected, sys.stderr.getvalue())
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
expected = ''
self.assertEquals(log_output, expected)
self.patched['wakatime.session_cache.SessionCache.get'].assert_not_called()
self.patched['wakatime.session_cache.SessionCache.delete'].assert_not_called()
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
self.patched['wakatime.offlinequeue.Queue.push'].assert_not_called()
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].assert_not_called()
开发者ID:wakatime,项目名称:wakatime,代码行数:34,代码来源:test_proxy.py
示例2: test_heartbeat_saved_when_requests_raises_exception
def test_heartbeat_saved_when_requests_raises_exception(self, logs):
logging.disable(logging.NOTSET)
with tempfile.NamedTemporaryFile() as fh:
with utils.mock.patch('wakatime.offlinequeue.Queue.get_db_file') as mock_db_file:
mock_db_file.return_value = fh.name
exception_msg = u("Oops, requests raised an exception. You're move.")
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].side_effect = AttributeError(exception_msg)
now = u(int(time.time()))
entity = 'tests/samples/codefiles/twolinefile.txt'
config = 'tests/samples/configs/good_config.cfg'
args = ['--file', entity, '--config', config, '--time', now]
execute(args)
queue = Queue()
saved_heartbeat = queue.pop()
self.assertEquals(os.path.realpath(entity), saved_heartbeat['entity'])
self.assertEquals(sys.stdout.getvalue(), '')
self.assertEquals(sys.stderr.getvalue(), '')
output = [u(' ').join(x) for x in logs.actual()]
self.assertIn(exception_msg, output[0])
self.patched['wakatime.session_cache.SessionCache.get'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.delete'].assert_has_calls([call(), call()])
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
开发者ID:awesome-archive,项目名称:wakatime,代码行数:30,代码来源:test_offlinequeue.py
示例3: test_verbose_flag_enables_verbose_logging
def test_verbose_flag_enables_verbose_logging(self, logs):
logging.disable(logging.NOTSET)
response = Response()
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
entity = 'tests/samples/codefiles/python.py'
config = 'tests/samples/configs/sample.cfg'
args = ['--file', entity, '--config', config, '--time', now, '--verbose']
retval = execute(args)
self.assertEquals(retval, 102)
self.assertEquals(sys.stdout.getvalue(), '')
self.assertEquals(sys.stderr.getvalue(), '')
self.assertEquals(logging.DEBUG, logging.getLogger('WakaTime').level)
logfile = os.path.realpath(os.path.expanduser('~/.wakatime.log'))
self.assertEquals(logfile, logging.getLogger('WakaTime').handlers[0].baseFilename)
output = [u(' ').join(x) for x in logs.actual()]
self.assertEquals(output[0], u('WakaTime WARNING Regex error (unbalanced parenthesis) for include pattern: \\(invalid regex)'))
self.assertEquals(output[1], u('WakaTime WARNING Regex error (unbalanced parenthesis) for exclude pattern: \\(invalid regex)'))
self.assertEquals(output[2], u('WakaTime DEBUG Sending heartbeat to api at https://wakatime.com/api/v1/heartbeats'))
self.assertIn('Python', output[3])
self.assertIn('response_code', output[4])
开发者ID:Thamaraiselvam,项目名称:wakatime,代码行数:26,代码来源:test_logging.py
示例4: test_legacy_hidefilenames_config_supported
def test_legacy_hidefilenames_config_supported(self):
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
with TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/python.py'
shutil.copy(entity, os.path.join(tempdir, 'python.py'))
entity = os.path.realpath(os.path.join(tempdir, 'python.py'))
now = u(int(time.time()))
config = 'tests/samples/configs/paranoid_legacy.cfg'
key = u(uuid.uuid4())
project = 'abcxyz'
args = ['--file', entity, '--key', key, '--config', config, '--time', now, '--log-file', '~/.wakatime.log', '--alternate-project', project]
retval = execute(args)
self.assertEquals(retval, SUCCESS)
self.assertNothingPrinted()
heartbeat = {
'language': 'Python',
'lines': None,
'entity': 'HIDDEN.py',
'project': project,
'time': float(now),
'is_write': False,
'type': 'file',
'dependencies': None,
'user_agent': ANY,
}
self.assertHeartbeatSent(heartbeat)
self.assertHeartbeatNotSavedOffline()
self.assertOfflineHeartbeatsSynced()
self.assertSessionCacheSaved()
开发者ID:wakatime,项目名称:wakatime,代码行数:34,代码来源:test_configs.py
示例5: test_does_not_hide_unmatching_filenames
def test_does_not_hide_unmatching_filenames(self):
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
with TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/python.py'
shutil.copy(entity, os.path.join(tempdir, 'python.py'))
entity = os.path.realpath(os.path.join(tempdir, 'python.py'))
now = u(int(time.time()))
config = 'tests/samples/configs/hide_file_names_not_python.cfg'
key = u(uuid.uuid4())
dependencies = ['sqlalchemy', 'jinja', 'simplejson', 'flask', 'app', 'django', 'pygments', 'unittest', 'mock']
project = 'abcxyz'
args = ['--file', entity, '--key', key, '--config', config, '--time', now, '--log-file', '~/.wakatime.log', '--alternate-project', project]
retval = execute(args)
self.assertEquals(retval, SUCCESS)
self.assertNothingPrinted()
heartbeat = {
'language': 'Python',
'lines': 37,
'entity': entity,
'project': project,
'time': float(now),
'is_write': False,
'type': 'file',
'dependencies': dependencies,
'user_agent': ANY,
}
self.assertHeartbeatSent(heartbeat)
self.assertHeartbeatNotSavedOffline()
self.assertOfflineHeartbeatsSynced()
self.assertSessionCacheSaved()
开发者ID:wakatime,项目名称:wakatime,代码行数:35,代码来源:test_configs.py
示例6: test_bad_config_file
def test_bad_config_file(self, logs):
logging.disable(logging.NOTSET)
with TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/emptyfile.txt'
shutil.copy(entity, os.path.join(tempdir, 'emptyfile.txt'))
entity = os.path.realpath(os.path.join(tempdir, 'emptyfile.txt'))
config = 'tests/samples/configs/bad_config.cfg'
args = ['--file', entity, '--config', config, '--log-file', '~/.wakatime.log']
with self.assertRaises(SystemExit) as e:
execute(args)
self.assertEquals(int(str(e.exception)), CONFIG_FILE_PARSE_ERROR)
self.assertIn('ParsingError', sys.stdout.getvalue())
expected_stderr = ''
self.assertEquals(sys.stderr.getvalue(), expected_stderr)
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
expected = ''
self.assertEquals(log_output, expected)
self.patched['wakatime.offlinequeue.Queue.push'].assert_not_called()
self.patched['wakatime.session_cache.SessionCache.get'].assert_not_called()
self.patched['wakatime.session_cache.SessionCache.delete'].assert_not_called()
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
开发者ID:wakatime,项目名称:wakatime,代码行数:27,代码来源:test_configs.py
示例7: test_unhandled_exception
def test_unhandled_exception(self, logs):
logging.disable(logging.NOTSET)
with utils.mock.patch('wakatime.main.send_heartbeats') as mock_send:
ex_msg = 'testing unhandled exception'
mock_send.side_effect = RuntimeError(ex_msg)
entity = 'tests/samples/codefiles/twolinefile.txt'
config = 'tests/samples/configs/good_config.cfg'
key = str(uuid.uuid4())
args = ['--entity', entity, '--key', key, '--config', config]
execute(args)
self.assertIn(ex_msg, sys.stdout.getvalue())
self.assertEquals(sys.stderr.getvalue(), '')
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
self.assertIn(ex_msg, log_output)
self.assertHeartbeatNotSent()
self.assertHeartbeatNotSavedOffline()
self.assertOfflineHeartbeatsNotSynced()
self.assertSessionCacheUntouched()
开发者ID:wakatime,项目名称:wakatime,代码行数:26,代码来源:test_main.py
示例8: test_timezone_with_invalid_encoding
def test_timezone_with_invalid_encoding(self):
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
with utils.TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/emptyfile.txt'
shutil.copy(entity, os.path.join(tempdir, 'emptyfile.txt'))
entity = os.path.realpath(os.path.join(tempdir, 'emptyfile.txt'))
class TZ(object):
@property
def zone(self):
return bytes('\xab', 'utf-16') if is_py3 else '\xab'
timezone = TZ()
with self.assertRaises(UnicodeDecodeError):
timezone.zone.decode('utf8')
with utils.mock.patch('wakatime.packages.tzlocal.get_localzone') as mock_getlocalzone:
mock_getlocalzone.return_value = timezone
timeout = 15
config = 'tests/samples/configs/has_everything.cfg'
args = ['--file', entity, '--config', config, '--timeout', u(timeout)]
retval = execute(args)
self.assertEquals(retval, SUCCESS)
self.assertNothingPrinted()
headers = {
'TimeZone': u(bytes('\xab', 'utf-16') if is_py3 else '\xab').encode('utf-8'),
}
self.assertHeartbeatSent(headers=headers, proxies=ANY, timeout=timeout)
self.assertHeartbeatNotSavedOffline()
self.assertOfflineHeartbeatsSynced()
self.assertSessionCacheSaved()
开发者ID:wakatime,项目名称:wakatime,代码行数:34,代码来源:test_main.py
示例9: test_requests_exception_without_offline_logging
def test_requests_exception_without_offline_logging(self, logs):
logging.disable(logging.NOTSET)
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].side_effect = RequestException('requests exception')
with utils.TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/twolinefile.txt'
shutil.copy(entity, os.path.join(tempdir, 'twolinefile.txt'))
entity = os.path.realpath(os.path.join(tempdir, 'twolinefile.txt'))
now = u(int(time.time()))
key = str(uuid.uuid4())
args = ['--file', entity, '--key', key, '--disable-offline',
'--config', 'tests/samples/configs/good_config.cfg', '--time', now]
retval = execute(args)
self.assertEquals(retval, API_ERROR)
self.assertNothingPrinted()
log_output = u("\n").join([u(' ').join(x) for x in logs.actual()])
expected = "WakaTime ERROR {'RequestException': u'requests exception'}"
if is_py3:
expected = "WakaTime ERROR {'RequestException': 'requests exception'}"
self.assertEquals(expected, log_output)
self.assertHeartbeatSent()
self.assertHeartbeatNotSavedOffline()
self.assertOfflineHeartbeatsNotSynced()
self.assertSessionCacheDeleted()
开发者ID:wakatime,项目名称:wakatime,代码行数:29,代码来源:test_main.py
示例10: test_php_dependencies_detected
def test_php_dependencies_detected(self):
response = Response()
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with utils.TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/php.php'
shutil.copy(entity, os.path.join(tempdir, 'php.php'))
entity = os.path.realpath(os.path.join(tempdir, 'php.php'))
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
args = ['--file', entity, '--config', config, '--time', now]
retval = execute(args)
self.assertEquals(retval, 102)
self.assertEquals(sys.stdout.getvalue(), '')
self.assertEquals(sys.stderr.getvalue(), '')
self.patched['wakatime.session_cache.SessionCache.get'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
heartbeat = {
'language': u('PHP'),
'lines': ANY,
'entity': os.path.realpath(entity),
'dependencies': ANY,
'project': u(os.path.basename(os.path.realpath('.'))),
'time': float(now),
'type': 'file',
}
stats = {
u('cursorpos'): None,
u('dependencies'): ANY,
u('language'): u('PHP'),
u('lineno'): None,
u('lines'): ANY,
}
expected_dependencies = [
'Interop',
'FooBarOne',
'FooBarTwo',
'FooBarThree',
'FooBarFour',
'FooBarSeven',
'FooBarEight',
'ArrayObject',
"'ServiceLocator.php'",
"'ServiceLocatorTwo.php'",
]
self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(ANY, ANY, None)
for key, val in self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].items():
self.assertEquals(heartbeat[key], val)
self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
dependencies = self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['dependencies']
self.assertListsEqual(dependencies, expected_dependencies)
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
开发者ID:awesome-archive,项目名称:wakatime,代码行数:60,代码来源:test_dependencies.py
示例11: test_go_dependencies_detected
def test_go_dependencies_detected(self):
response = Response()
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with utils.TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/go.go'
shutil.copy(entity, os.path.join(tempdir, 'go.go'))
entity = os.path.realpath(os.path.join(tempdir, 'go.go'))
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
args = ['--file', entity, '--config', config, '--time', now]
retval = execute(args)
self.assertEquals(retval, 102)
self.assertEquals(sys.stdout.getvalue(), '')
self.assertEquals(sys.stderr.getvalue(), '')
self.patched['wakatime.session_cache.SessionCache.get'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
heartbeat = {
'language': u('Go'),
'lines': 24,
'entity': os.path.realpath(entity),
'project': u(os.path.basename(os.path.realpath('.'))),
'dependencies': ANY,
'time': float(now),
'type': 'file',
}
stats = {
u('cursorpos'): None,
u('dependencies'): ANY,
u('language'): u('Go'),
u('lineno'): None,
u('lines'): 24,
}
expected_dependencies = [
'"compress/gzip"',
'"direct"',
'"foobar"',
'"github.com/golang/example/stringutil"',
'"image/gif"',
'"log"',
'"math"',
'"oldname"',
'"os"',
'"supress"',
]
self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(ANY, ANY, None)
for key, val in self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].items():
self.assertEquals(heartbeat[key], val)
dependencies = self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['dependencies']
self.assertListsEqual(dependencies, expected_dependencies)
self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
开发者ID:awesome-archive,项目名称:wakatime,代码行数:60,代码来源:test_dependencies.py
示例12: test_python_dependencies_detected
def test_python_dependencies_detected(self):
response = Response()
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
with utils.TemporaryDirectory() as tempdir:
entity = 'tests/samples/codefiles/python.py'
shutil.copy(entity, os.path.join(tempdir, 'python.py'))
entity = os.path.realpath(os.path.join(tempdir, 'python.py'))
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
args = ['--file', entity, '--config', config, '--time', now]
retval = execute(args)
self.assertEquals(retval, 102)
self.assertEquals(sys.stdout.getvalue(), '')
self.assertEquals(sys.stderr.getvalue(), '')
self.patched['wakatime.session_cache.SessionCache.get'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
heartbeat = {
'language': u('Python'),
'lines': 36,
'entity': os.path.realpath(entity),
'project': u(os.path.basename(os.path.realpath('.'))),
'dependencies': ANY,
'time': float(now),
'type': 'file',
}
stats = {
u('cursorpos'): None,
u('dependencies'): ANY,
u('language'): u('Python'),
u('lineno'): None,
u('lines'): 36,
}
expected_dependencies = [
'app',
'django',
'flask',
'jinja',
'mock',
'pygments',
'simplejson',
'sqlalchemy',
'unittest',
]
self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(ANY, ANY, None)
for key, val in self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].items():
self.assertEquals(heartbeat[key], val)
dependencies = self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['dependencies']
self.assertListsEqual(dependencies, expected_dependencies)
self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
开发者ID:awesome-archive,项目名称:wakatime,代码行数:59,代码来源:test_dependencies.py
示例13: test_python_dependencies_detected
def test_python_dependencies_detected(self):
response = Response()
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
entity = 'tests/samples/codefiles/python.py'
config = 'tests/samples/configs/good_config.cfg'
args = ['--file', entity, '--config', config, '--time', now]
retval = execute(args)
self.assertEquals(retval, 102)
self.assertEquals(sys.stdout.getvalue(), '')
self.assertEquals(sys.stderr.getvalue(), '')
self.patched['wakatime.session_cache.SessionCache.get'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.delete'].assert_called_once_with()
self.patched['wakatime.session_cache.SessionCache.save'].assert_not_called()
heartbeat = {
'language': u('Python'),
'lines': 36,
'entity': os.path.realpath(entity),
'project': u(os.path.basename(os.path.realpath('.'))),
'dependencies': ANY,
'branch': os.environ.get('TRAVIS_COMMIT', ANY),
'time': float(now),
'type': 'file',
}
stats = {
u('cursorpos'): None,
u('dependencies'): ANY,
u('language'): u('Python'),
u('lineno'): None,
u('lines'): 36,
}
expected_dependencies = [
'app',
'django',
'flask',
'jinja',
'mock',
'os',
'pygments',
'simplejson',
'sqlalchemy',
'sys',
'unittest',
]
def normalize(items):
return sorted([u(x) for x in items])
self.patched['wakatime.offlinequeue.Queue.push'].assert_called_once_with(heartbeat, ANY, None)
dependencies = self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['dependencies']
self.assertEquals(normalize(dependencies), normalize(expected_dependencies))
self.assertEquals(stats, json.loads(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][1]))
self.patched['wakatime.offlinequeue.Queue.pop'].assert_not_called()
开发者ID:CodeCavePro,项目名称:wakatime-unity,代码行数:59,代码来源:test_dependencies.py
示例14: test_cpp_language_detected_for_header_with_c_and_cpp_files_in_folder
def test_cpp_language_detected_for_header_with_c_and_cpp_files_in_folder(self):
response = Response()
response.status_code = 500
self.patched["wakatime.packages.requests.adapters.HTTPAdapter.send"].return_value = response
now = u(int(time.time()))
config = "tests/samples/configs/good_config.cfg"
entity = "tests/samples/codefiles/c_and_cpp/empty.h"
args = ["--file", entity, "--config", config, "--time", now]
retval = execute(args)
self.assertEquals(retval, 102)
language = u("C++")
self.assertEqual(self.patched["wakatime.offlinequeue.Queue.push"].call_args[0][0]["language"], language)
开发者ID:Phyllostachys,项目名称:dotatom,代码行数:15,代码来源:test_languages.py
示例15: test_guess_language_from_vim_modeline
def test_guess_language_from_vim_modeline(self):
response = Response()
response.status_code = 500
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python_without_extension'
args = ['--file', entity, '--config', config, '--time', now]
retval = execute(args)
self.assertEquals(retval, 102)
language = u('Python')
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language)
开发者ID:itimetrack,项目名称:itimetrack,代码行数:15,代码来源:test_languages.py
示例16: test_cpp_language_detected_for_header_with_c_and_cpp_files_in_folder
def test_cpp_language_detected_for_header_with_c_and_cpp_files_in_folder(self):
response = Response()
response.status_code = 500
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/c_and_cpp/empty.h'
args = ['--file', entity, '--config', config, '--time', now]
retval = execute(args)
self.assertEquals(retval, 102)
language = u('C++')
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language)
开发者ID:itimetrack,项目名称:itimetrack,代码行数:15,代码来源:test_languages.py
示例17: test_alternate_language_not_used_when_guessed
def test_alternate_language_not_used_when_guessed(self):
response = Response()
response.status_code = 500
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
now = u(int(time.time()))
config = 'tests/samples/configs/good_config.cfg'
entity = 'tests/samples/codefiles/python.py'
args = ['--file', entity, '--config', config, '--time', now, '--alternate-language', 'java']
retval = execute(args)
self.assertEquals(retval, 102)
language = u('Python')
self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language)
开发者ID:itimetrack,项目名称:itimetrack,代码行数:15,代码来源:test_languages.py
示例18: shared
def shared(self, expected_project='', expected_branch=ANY, entity='', config='good_config.cfg', extra_args=[]):
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = CustomResponse()
config = os.path.join('tests/samples/configs', config)
if not os.path.exists(entity):
entity = os.path.realpath(os.path.join('tests/samples', entity))
now = u(int(time.time()))
args = ['--file', entity, '--config', config, '--time', now] + extra_args
retval = execute(args)
self.assertEquals(retval, SUCCESS)
self.assertNothingPrinted()
heartbeat = {
'language': ANY,
'lines': ANY,
'entity': os.path.realpath(entity),
'project': expected_project,
'branch': expected_branch,
'dependencies': ANY,
'time': float(now),
'type': 'file',
'is_write': False,
'user_agent': ANY,
}
self.assertHeartbeatSent(heartbeat)
self.assertHeartbeatNotSavedOffline()
self.assertOfflineHeartbeatsSynced()
self.assertSessionCacheSaved()
开发者ID:wakatime,项目名称:wakatime,代码行数:31,代码来源:test_project.py
示例19: test_get_project_not_used_when_project_names_hidden
def test_get_project_not_used_when_project_names_hidden(self):
response = Response()
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
tempdir = tempfile.mkdtemp()
shutil.copytree('tests/samples/projects/git', os.path.join(tempdir, 'git'))
shutil.move(os.path.join(tempdir, 'git', 'dot_git'), os.path.join(tempdir, 'git', '.git'))
now = u(int(time.time()))
entity = os.path.join(tempdir, 'git', 'emptyfile.txt')
config = 'tests/samples/configs/good_config.cfg'
args = ['--hide-project-names', '--file', entity, '--config', config, '--time', now]
execute(args)
self.assertHeartbeatSavedOffline()
self.assertNotEquals('git', self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])
self.assertEquals(None, self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['branch'])
proj = open(os.path.join(tempdir, 'git', '.wakatime-project')).read()
self.assertEquals(proj, self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])
execute(args)
self.assertEquals(proj, self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0]['project'])
开发者ID:wakatime,项目名称:wakatime,代码行数:26,代码来源:test_project.py
示例20: test_alternate_project_argument_used_when_project_not_detected
def test_alternate_project_argument_used_when_project_not_detected(self):
response = Response()
response.status_code = 0
self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response
tempdir = tempfile.mkdtemp()
entity = 'tests/samples/projects/git/emptyfile.txt'
shutil.copy(entity, os.path.join(tempdir, 'emptyfile.txt'))
now = u(int(time.time()))
entity = os.path.join(tempdir, 'emptyfile.txt')
config = 'tests/samples/configs/good_config.cfg'
args = ['--file', entity, '--config', config, '--time', now]
execute(args)
args = ['--file', entity, '--config', config, '--time', now, '--alternate-project', 'alt-project']
execute(args)
calls = self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].call_args_list
body = calls[0][0][0].body
data = json.loads(body)[0]
self.assertEquals(None, data.get('project'))
body = calls[1][0][0].body
data = json.loads(body)[0]
self.assertEquals('alt-project', data['project'])
开发者ID:wakatime,项目名称:wakatime,代码行数:28,代码来源:test_project.py
注:本文中的wakatime.compat.u函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论