buggy
stringlengths
35
5.03k
fixed
stringlengths
46
62.5k
class BaseDatabaseOperations: "subclasses of BaseDatabaseOperations may require a time_trunc_sql() method" ) def time_extract_sql(self, lookup_type, field_name): """ Given a lookup_type of 'hour', 'minute', or 'second', return the SQL that extracts a value from the given...
class BaseDatabaseOperations: "subclasses of BaseDatabaseOperations may require a time_trunc_sql() method" ) def time_extract_sql(self, lookup_type, sql, params): """ Given a lookup_type of 'hour', 'minute', or 'second', return the SQL that extracts a value from the give...
from django.db.models import Exists, ExpressionWrapper, Lookup from django.db.models.constants import OnConflict from django.utils import timezone from django.utils.encoding import force_str class DatabaseOperations(BaseDatabaseOperations):
from django.db.models import Exists, ExpressionWrapper, Lookup from django.db.models.constants import OnConflict from django.utils import timezone from django.utils.encoding import force_str from django.utils.regex_helper import _lazy_re_compile class DatabaseOperations(BaseDatabaseOperations):
class DatabaseOperations(BaseDatabaseOperations): cast_char_field_without_max_length = "char" explain_prefix = "EXPLAIN" def date_extract_sql(self, lookup_type, field_name): # https://dev.mysql.com/doc/mysql/en/date-and-time-functions.html if lookup_type == "week_day": # DAYOFWE...
class DatabaseOperations(BaseDatabaseOperations): cast_char_field_without_max_length = "char" explain_prefix = "EXPLAIN" # EXTRACT format cannot be passed in parameters. _extract_format_re = _lazy_re_compile(r"[A-Z_]+") def date_extract_sql(self, lookup_type, sql, params): # https://dev.my...
END; f"ORDER BY {cache_key} OFFSET %%s ROWS FETCH FIRST 1 ROWS ONLY" ) def date_extract_sql(self, lookup_type, field_name): if lookup_type == "week_day": # TO_CHAR(field, 'D') returns an integer from 1-7, where 1=Sunday. return "TO_CHAR(%s, 'D')" % field_name ...
END; f"ORDER BY {cache_key} OFFSET %%s ROWS FETCH FIRST 1 ROWS ONLY" ) # EXTRACT format cannot be passed in parameters. _extract_format_re = _lazy_re_compile(r"[A-Z_]+") def date_extract_sql(self, lookup_type, sql, params): extract_sql = f"TO_CHAR({sql}, %s)" extract_pa...
END; tzname, sign, offset = split_tzname_delta(tzname) return f"{sign}{offset}" if offset else tzname def _convert_field_to_tz(self, field_name, tzname): if not (settings.USE_TZ and tzname): return field_name if not self._tzname_re.match(tzname): raise ValueE...
END; tzname, sign, offset = split_tzname_delta(tzname) return f"{sign}{offset}" if offset else tzname def _convert_field_to_tz(self, sql, params, tzname): if not (settings.USE_TZ and tzname): return sql, params if not self._tzname_re.match(tzname): raise Valu...
class DatabaseOperations(BaseDatabaseOperations): ) return "%s" def date_extract_sql(self, lookup_type, field_name): # https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT if lookup_type == "week_day": # For consistency across ba...
class DatabaseOperations(BaseDatabaseOperations): ) return "%s" def date_extract_sql(self, lookup_type, sql, params): # https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT extract_sql = f"EXTRACT(%s FROM {sql})" extract_param = look...
class DatabaseOperations(BaseDatabaseOperations): return f"{tzname}{sign}{offset}" return tzname def _convert_field_to_tz(self, field_name, tzname): if tzname and settings.USE_TZ: field_name = "%s AT TIME ZONE '%s'" % ( field_name, self._prepa...
class DatabaseOperations(BaseDatabaseOperations): return f"{tzname}{sign}{offset}" return tzname def _convert_sql_to_tz(self, sql, params, tzname): if tzname and settings.USE_TZ: tzname_param = self._prepare_tzname_delta(tzname) return f"{sql} AT TIME ZONE %s", (...
class DatabaseOperations(BaseDatabaseOperations): "accepting multiple arguments." ) def date_extract_sql(self, lookup_type, field_name): """ Support EXTRACT with a user-defined function django_date_extract() that's registered in connect(). Use single quotes becau...
class DatabaseOperations(BaseDatabaseOperations): "accepting multiple arguments." ) def date_extract_sql(self, lookup_type, sql, params): """ Support EXTRACT with a user-defined function django_date_extract() that's registered in connect(). Use single quotes beca...
class DatabaseOperations(BaseDatabaseOperations): """Do nothing since formatting is handled in the custom function.""" return sql def date_trunc_sql(self, lookup_type, field_name, tzname=None): return "django_date_trunc('%s', %s, %s, %s)" % ( lookup_type.lower(), fie...
class DatabaseOperations(BaseDatabaseOperations): """Do nothing since formatting is handled in the custom function.""" return sql def date_trunc_sql(self, lookup_type, sql, params, tzname=None): return f"django_date_trunc(%s, {sql}, %s, %s)", ( lookup_type.lower(), *...
class Extract(TimezoneMixin, Transform): super().__init__(expression, **extra) def as_sql(self, compiler, connection): if not connection.ops.extract_trunc_lookup_pattern.fullmatch(self.lookup_name): raise ValueError("Invalid lookup_name: %s" % self.lookup_name) sql, params = com...
class Extract(TimezoneMixin, Transform): super().__init__(expression, **extra) def as_sql(self, compiler, connection): sql, params = compiler.compile(self.lhs) lhs_output_field = self.lhs.output_field if isinstance(lhs_output_field, DateTimeField): tzname = self.get_tzna...
class TruncBase(TimezoneMixin, Transform): super().__init__(expression, output_field=output_field, **extra) def as_sql(self, compiler, connection): if not connection.ops.extract_trunc_lookup_pattern.fullmatch(self.kind): raise ValueError("Invalid kind: %s" % self.kind) inner_sql...
class TruncBase(TimezoneMixin, Transform): super().__init__(expression, output_field=output_field, **extra) def as_sql(self, compiler, connection): sql, params = compiler.compile(self.lhs) tzname = None if isinstance(self.lhs.output_field, DateTimeField): tzname = self.g...
class TruncDate(TruncBase): def as_sql(self, compiler, connection): # Cast to date rather than truncate to date. lhs, lhs_params = compiler.compile(self.lhs) tzname = self.get_tzname() sql = connection.ops.datetime_cast_date_sql(lhs, tzname) return sql, lhs_params class Tr...
class TruncDate(TruncBase): def as_sql(self, compiler, connection): # Cast to date rather than truncate to date. sql, params = compiler.compile(self.lhs) tzname = self.get_tzname() return connection.ops.datetime_cast_date_sql(sql, tuple(params), tzname) class TruncTime(TruncBase):
class TruncTime(TruncBase): def as_sql(self, compiler, connection): # Cast to time rather than truncate to time. lhs, lhs_params = compiler.compile(self.lhs) tzname = self.get_tzname() sql = connection.ops.datetime_cast_time_sql(lhs, tzname) return sql, lhs_params class Tr...
class TruncTime(TruncBase): def as_sql(self, compiler, connection): # Cast to time rather than truncate to time. sql, params = compiler.compile(self.lhs) tzname = self.get_tzname() return connection.ops.datetime_cast_time_sql(sql, tuple(params), tzname) class TruncHour(TruncBase):
class SimpleDatabaseOperationTests(SimpleTestCase): with self.assertRaisesMessage( NotImplementedError, self.may_require_msg % "date_extract_sql" ): self.ops.date_extract_sql(None, None) def test_time_extract_sql(self): with self.assertRaisesMessage( NotI...
class SimpleDatabaseOperationTests(SimpleTestCase): with self.assertRaisesMessage( NotImplementedError, self.may_require_msg % "date_extract_sql" ): self.ops.date_extract_sql(None, None, None) def test_time_extract_sql(self): with self.assertRaisesMessage( ...
class YearTransform(models.Transform): def as_sql(self, compiler, connection): lhs_sql, params = compiler.compile(self.lhs) return connection.ops.date_extract_sql("year", lhs_sql), params @property def output_field(self):
class YearTransform(models.Transform): def as_sql(self, compiler, connection): lhs_sql, params = compiler.compile(self.lhs) return connection.ops.date_extract_sql("year", lhs_sql, params) @property def output_field(self):
except ImportError: pytz = None from django.conf import settings from django.db.models import ( DateField, DateTimeField,
except ImportError: pytz = None from django.conf import settings from django.db import DataError, OperationalError from django.db.models import ( DateField, DateTimeField,
class DateFunctionTests(TestCase): self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) msg = "Invalid lookup_name: " with self.assertRaisesMessage(ValueError, msg): DTModel.objects.filter( start_datetime__year=Extra...
class DateFunctionTests(TestCase): self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) with self.assertRaises((DataError, OperationalError, ValueError)): DTModel.objects.filter( start_datetime__year=Extract( ...
class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) msg = "Invalid kind: " with self.assertRaisesMessage(ValueError, msg): DTModel.objec...
class DateFunctionTests(TestCase): end_datetime = timezone.make_aware(end_datetime) self.create_model(start_datetime, end_datetime) self.create_model(end_datetime, start_datetime) # Database backends raise an exception or don't return any results. try: exists = DT...
class SimpleTaskState(object): elif task.scheduler_disable_time is not None: return if new_status == FAILED and task.can_disable(): task.add_failure() if task.has_excessive_failures(): task.scheduler_disable_time = time.time()
class SimpleTaskState(object): elif task.scheduler_disable_time is not None: return if new_status == FAILED and task.can_disable() and task.status != DISABLED: task.add_failure() if task.has_excessive_failures(): task.scheduler_disable_time = ...
class CentralPlannerTest(unittest.TestCase): self.sch.add_task(worker=WORKER, task_id='A') self.assertEqual(self.sch.get_work(worker=WORKER)['task_id'], 'A') def test_disable_by_worker(self): self.sch.add_task(worker=WORKER, task_id='A', status=DISABLED) self.assertEqual(len(self.sc...
class CentralPlannerTest(unittest.TestCase): self.sch.add_task(worker=WORKER, task_id='A') self.assertEqual(self.sch.get_work(worker=WORKER)['task_id'], 'A') def test_automatic_re_enable(self): self.sch = CentralPlannerScheduler(disable_failures=2, disable_persist=100) self.setTime(...
def history_without_current(mocker): ('vom file.py', 'vom: not found'), ('fucck', 'fucck: not found'), ('got commit', 'got: command not found')]) def test_match(script, stderr): assert match(Command(script, stderr=stderr)) @pytest.mark.usefixtures('no_memoize') @pytest.mark.parametrize('script, stderr...
def history_without_current(mocker): ('vom file.py', 'vom: not found'), ('fucck', 'fucck: not found'), ('got commit', 'got: command not found')]) def test_match(mocker, script, stderr): mocker.patch('thefuck.rules.no_command.which', return_value=None) assert match(Command(script, stderr=stderr)) ...
from difflib import get_close_matches from thefuck.utils import get_all_executables, \ get_valid_history_without_current, get_closest from thefuck.specific.sudo import sudo_support @sudo_support def match(command): return (command.script_parts and 'not found' in command.stderr and bool...
from difflib import get_close_matches from thefuck.utils import get_all_executables, \ get_valid_history_without_current, get_closest, which from thefuck.specific.sudo import sudo_support @sudo_support def match(command): return (not which(command.script_parts[0]) and 'not found' in command.stderr...
def dispatch_to_series(left, right, func, str_rep=None, axis=None): # in which case we specifically want to operate row-by-row assert right.index.equals(left.columns) def column_op(a, b): return {i: func(a.iloc[:, i], b.iloc[i]) for i in range(len(a.columns))} elif isinstance(r...
def dispatch_to_series(left, right, func, str_rep=None, axis=None): # in which case we specifically want to operate row-by-row assert right.index.equals(left.columns) if right.dtype == "timedelta64[ns]": # ensure we treat NaT values as the correct dtype # Note: we do not...
class TestFrameFlexArithmetic: class TestFrameArithmetic: def test_df_add_2d_array_rowlike_broadcasts(self): # GH#23000 arr = np.arange(6).reshape(3, 2)
class TestFrameFlexArithmetic: class TestFrameArithmetic: def test_td64_op_nat_casting(self): # Make sure we don't accidentally treat timedelta64(NaT) as datetime64 # when calling dispatch_to_series in DataFrame arithmetic ser = pd.Series(["NaT", "NaT"], dtype="timedelta64[ns]") d...
from django.db import NotSupportedError, transaction from django.db.backends import utils from django.utils import timezone from django.utils.encoding import force_str class BaseDatabaseOperations:
from django.db import NotSupportedError, transaction from django.db.backends import utils from django.utils import timezone from django.utils.encoding import force_str from django.utils.regex_helper import _lazy_re_compile class BaseDatabaseOperations:
class BaseDatabaseOperations: # Prefix for EXPLAIN queries, or None EXPLAIN isn't supported. explain_prefix = None def __init__(self, connection): self.connection = connection self._cache = None
class BaseDatabaseOperations: # Prefix for EXPLAIN queries, or None EXPLAIN isn't supported. explain_prefix = None extract_trunc_lookup_pattern = _lazy_re_compile(r"[\w\-_()]+") def __init__(self, connection): self.connection = connection self._cache = None
class Extract(TimezoneMixin, Transform): super().__init__(expression, **extra) def as_sql(self, compiler, connection): sql, params = compiler.compile(self.lhs) lhs_output_field = self.lhs.output_field if isinstance(lhs_output_field, DateTimeField):
class Extract(TimezoneMixin, Transform): super().__init__(expression, **extra) def as_sql(self, compiler, connection): if not connection.ops.extract_trunc_lookup_pattern.fullmatch(self.lookup_name): raise ValueError("Invalid lookup_name: %s" % self.lookup_name) sql, params = com...
class TruncBase(TimezoneMixin, Transform): super().__init__(expression, output_field=output_field, **extra) def as_sql(self, compiler, connection): inner_sql, inner_params = compiler.compile(self.lhs) tzname = None if isinstance(self.lhs.output_field, DateTimeField):
class TruncBase(TimezoneMixin, Transform): super().__init__(expression, output_field=output_field, **extra) def as_sql(self, compiler, connection): if not connection.ops.extract_trunc_lookup_pattern.fullmatch(self.kind): raise ValueError("Invalid kind: %s" % self.kind) inner_sql...
class DateFunctionTests(TestCase): self.assertEqual(qs.count(), 1) self.assertGreaterEqual(str(qs.query).lower().count("extract"), 2) def test_extract_func(self): start_datetime = datetime(2015, 6, 15, 14, 30, 50, 321) end_datetime = datetime(2016, 6, 15, 14, 10, 50,...
class DateFunctionTests(TestCase): self.assertEqual(qs.count(), 1) self.assertGreaterEqual(str(qs.query).lower().count("extract"), 2) def test_extract_lookup_name_sql_injection(self): start_datetime = datetime(2015, 6, 15, 14, 30, 50, 321) end_datetime = datetime(201...
class DateFunctionTests(TestCase): [obj], ) def test_trunc_func(self): start_datetime = datetime(999, 6, 15, 14, 30, 50, 321) end_datetime = datetime(2016, 6, 15, 14, 10, 50, 123)
class DateFunctionTests(TestCase): [obj], ) def test_trunc_lookup_name_sql_injection(self): start_datetime = datetime(2015, 6, 15, 14, 30, 50, 321) end_datetime = datetime(2016, 6, 15, 14, 10, 50, 123) if settings.USE_TZ: start_datetime = timezone.make_aware(...
def gen_python_files_in_dir( """Generate all files under `path` whose paths are not excluded by the `exclude` regex, but are included by the `include` regex. `report` is where output about exclusions goes. """ assert root.is_absolute(), f"INTERNAL ERROR: `root` must be absolute but is {root}" f...
def gen_python_files_in_dir( """Generate all files under `path` whose paths are not excluded by the `exclude` regex, but are included by the `include` regex. Symbolic links pointing outside of the root directory are ignored. `report` is where output about exclusions goes. """ assert root.is_ab...
import sys from tempfile import TemporaryDirectory from typing import Any, BinaryIO, Generator, List, Tuple, Iterator import unittest from unittest.mock import patch from click import unstyle from click.testing import CliRunner
import sys from tempfile import TemporaryDirectory from typing import Any, BinaryIO, Generator, List, Tuple, Iterator import unittest from unittest.mock import patch, MagicMock from click import unstyle from click.testing import CliRunner
class BlackTestCase(unittest.TestCase): with self.assertRaises(AssertionError): black.assert_equivalent("{}", "None") if __name__ == "__main__": unittest.main(module="test_black")
class BlackTestCase(unittest.TestCase): with self.assertRaises(AssertionError): black.assert_equivalent("{}", "None") def test_symlink_out_of_root_directory(self) -> None: # prepare argumens path = MagicMock() root = THIS_DIR child = MagicMock() include =...
class JSON(object): json_renderer_factory = JSON() # bw compat JSONP_VALID_CALLBACK = re.compile(r"^[a-zA-Z_$][0-9a-zA-Z_$]+$") class JSONP(JSON): """ `JSONP <http://en.wikipedia.org/wiki/JSONP>`_ renderer factory helper
class JSON(object): json_renderer_factory = JSON() # bw compat JSONP_VALID_CALLBACK = re.compile(r"^[$a-z_][$0-9a-z_\.\[\]]+[^.]$", re.I) class JSONP(JSON): """ `JSONP <http://en.wikipedia.org/wiki/JSONP>`_ renderer factory helper
class JSONP(JSON): raise HTTPBadRequest('Invalid JSONP callback function name.') ct = 'application/javascript' body = '%s(%s);' % (callback, val) response = request.response if response.content_type == response.default_cont...
class JSONP(JSON): raise HTTPBadRequest('Invalid JSONP callback function name.') ct = 'application/javascript' body = '/**/{0}({1});'.format(callback, val) response = request.response if response.content_type == response.de...
class TestJSONP(unittest.TestCase): request = testing.DummyRequest() request.GET['callback'] = 'callback' result = renderer({'a':'1'}, {'request':request}) self.assertEqual(result, 'callback({"a": "1"});') self.assertEqual(request.response.content_type, '...
class TestJSONP(unittest.TestCase): request = testing.DummyRequest() request.GET['callback'] = 'callback' result = renderer({'a':'1'}, {'request':request}) self.assertEqual(result, '/**/callback({"a": "1"});') self.assertEqual(request.response.content_type, ...
class GroupBy(_GroupBy): base_func = getattr(libgroupby, how) for name, obj in self._iterate_slices(): if aggregate: result_sz = ngroups else: result_sz = len(obj.values) if not cython_dtype: cython_dtype = obj.values....
class GroupBy(_GroupBy): base_func = getattr(libgroupby, how) for name, obj in self._iterate_slices(): values = obj._data._values if aggregate: result_sz = ngroups else: result_sz = len(values) if not cython_dtype: ...
class GroupBy(_GroupBy): func(**kwargs) # Call func to modify indexer values in place if result_is_index: result = algorithms.take_nd(obj.values, result) if post_processing: result = post_processing(result, inferences)
class GroupBy(_GroupBy): func(**kwargs) # Call func to modify indexer values in place if result_is_index: result = algorithms.take_nd(values, result) if post_processing: result = post_processing(result, inferences)
def test_groupby_axis_1(group_name): results = df.groupby(group_name, axis=1).sum() expected = df.T.groupby(group_name).sum().T assert_frame_equal(results, expected)
def test_groupby_axis_1(group_name): results = df.groupby(group_name, axis=1).sum() expected = df.T.groupby(group_name).sum().T assert_frame_equal(results, expected) @pytest.mark.parametrize( "op, expected", [ ( "shift", { "time": [ ...
from pandas._libs.lib import infer_dtype from pandas.core.dtypes.common import ( _NS_DTYPE, ensure_int64, is_categorical_dtype, is_datetime64_dtype, is_datetime64tz_dtype,
from pandas._libs.lib import infer_dtype from pandas.core.dtypes.common import ( _NS_DTYPE, ensure_int64, is_bool_dtype, is_categorical_dtype, is_datetime64_dtype, is_datetime64tz_dtype,
def _bins_to_cuts( def _coerce_to_type(x): """ if the passed data is of datetime/timedelta type, this method converts it to numeric so that cut method can handle it """ dtype = None
def _bins_to_cuts( def _coerce_to_type(x): """ if the passed data is of datetime/timedelta or bool type, this method converts it to numeric so that cut or qcut method can handle it """ dtype = None
def _coerce_to_type(x): elif is_timedelta64_dtype(x): x = to_timedelta(x) dtype = np.dtype("timedelta64[ns]") if dtype is not None: # GH 19768: force NaT to NaN during integer conversion
def _coerce_to_type(x): elif is_timedelta64_dtype(x): x = to_timedelta(x) dtype = np.dtype("timedelta64[ns]") elif is_bool_dtype(x): # GH 20303 x = x.astype(np.int64) if dtype is not None: # GH 19768: force NaT to NaN during integer conversion
def test_timedelta_cut_roundtrip(): ["0 days 23:57:07.200000", "2 days 00:00:00", "3 days 00:00:00"] ) tm.assert_index_equal(result_bins, expected_bins)
def test_timedelta_cut_roundtrip(): ["0 days 23:57:07.200000", "2 days 00:00:00", "3 days 00:00:00"] ) tm.assert_index_equal(result_bins, expected_bins) @pytest.mark.parametrize("bins", [6, 7]) @pytest.mark.parametrize( "box, compare", [ (Series, tm.assert_series_equal), (np.ar...
def test_date_like_qcut_bins(arg, expected_bins): ser = Series(arg) result, result_bins = qcut(ser, 2, retbins=True) tm.assert_index_equal(result_bins, expected_bins)
def test_date_like_qcut_bins(arg, expected_bins): ser = Series(arg) result, result_bins = qcut(ser, 2, retbins=True) tm.assert_index_equal(result_bins, expected_bins) @pytest.mark.parametrize("bins", [6, 7]) @pytest.mark.parametrize( "box, compare", [ (Series, tm.assert_series_equal), ...
from django.db.models.sql.where import ( ) from django.utils.deprecation import RemovedInDjango40Warning from django.utils.functional import cached_property from django.utils.tree import Node __all__ = ['Query', 'RawQuery'] def get_field_names_from_opts(opts): return set(chain.from_iterable(
from django.db.models.sql.where import ( ) from django.utils.deprecation import RemovedInDjango40Warning from django.utils.functional import cached_property from django.utils.regex_helper import _lazy_re_compile from django.utils.tree import Node __all__ = ['Query', 'RawQuery'] # Quotation marks ('"`[]), whitespace c...
class Query(BaseExpression): alias = seen[int_model] = join_info.joins[-1] return alias or seen[None] def add_annotation(self, annotation, alias, is_summary=False, select=True): """Add a single annotation expression to the Query.""" annotation = annotation.resolve_expression(sel...
class Query(BaseExpression): alias = seen[int_model] = join_info.joins[-1] return alias or seen[None] def check_alias(self, alias): if FORBIDDEN_ALIAS_PATTERN.search(alias): raise ValueError( "Column aliases cannot contain whitespace characters, quotation mar...
class Query(BaseExpression): else: param_iter = iter([]) for name, entry in select.items(): entry = str(entry) entry_params = [] pos = entry.find("%s")
class Query(BaseExpression): else: param_iter = iter([]) for name, entry in select.items(): self.check_alias(name) entry = str(entry) entry_params = [] pos = entry.find("%s")
class AggregateTestCase(TestCase): ('Stuart Russell', 1), ('Peter Norvig', 2), ], lambda a: (a.name, a.contact_count), ordered=False)
class AggregateTestCase(TestCase): ('Stuart Russell', 1), ('Peter Norvig', 2), ], lambda a: (a.name, a.contact_count), ordered=False) def test_alias_sql_injection(self): crafted_alias = """injected_name" from "aggregation_author"; --""" msg = ( "Column al...
class NonAggregateAnnotationTestCase(TestCase): {'name': 'Wesley J. Chun', 'max_pages': 0}, ]) class AliasTests(TestCase): @classmethod
class NonAggregateAnnotationTestCase(TestCase): {'name': 'Wesley J. Chun', 'max_pages': 0}, ]) def test_alias_sql_injection(self): crafted_alias = """injected_name" from "annotations_book"; --""" msg = ( "Column aliases cannot contain whitespace characters, quotation...
class AliasTests(TestCase): with self.subTest(operation=operation): with self.assertRaisesMessage(FieldError, msg): getattr(qs, operation)('rating_alias')
class AliasTests(TestCase): with self.subTest(operation=operation): with self.assertRaisesMessage(FieldError, msg): getattr(qs, operation)('rating_alias') def test_alias_sql_injection(self): crafted_alias = """injected_name" from "annotations_book"; --""" ...
class ValuesExpressionsTests(TestCase): [{'salary': 10}, {'salary': 20}, {'salary': 30}], ) def test_values_expression_group_by(self): # values() applies annotate() first, so values selected are grouped by # id, not firstname.
class ValuesExpressionsTests(TestCase): [{'salary': 10}, {'salary': 20}, {'salary': 30}], ) def test_values_expression_alias_sql_injection(self): crafted_alias = """injected_name" from "expressions_company"; --""" msg = ( "Column aliases cannot contain whitespace cha...
class Queries5Tests(TestCase): 'bar %s' ) class SelectRelatedTests(TestCase): def test_tickets_3045_3288(self):
class Queries5Tests(TestCase): 'bar %s' ) def test_extra_select_alias_sql_injection(self): crafted_alias = """injected_name" from "queries_note"; --""" msg = ( "Column aliases cannot contain whitespace characters, quotation marks, " "semicolons, or SQL co...
https://support.sas.com/techsup/technote/ts140.pdf """ from collections import abc from datetime import datetime from io import BytesIO import struct import warnings
https://support.sas.com/techsup/technote/ts140.pdf """ from collections import abc from datetime import datetime import struct import warnings
class XportReader(abc.Iterator): if isinstance(filepath_or_buffer, (str, bytes)): self.filepath_or_buffer = open(filepath_or_buffer, "rb") else: # Copy to BytesIO, and ensure no encoding contents = filepath_or_buffer.read() try: contents = ...
class XportReader(abc.Iterator): if isinstance(filepath_or_buffer, (str, bytes)): self.filepath_or_buffer = open(filepath_or_buffer, "rb") else: # Since xport files include non-text byte sequences, xport files # should already be opened in binary mode in Python 3. ...
class TestXport: self.dirpath = datapath("io", "sas", "data") self.file01 = os.path.join(self.dirpath, "DEMO_G.xpt") self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt") self.file03 = os.path.join(self.dirpath, "DRXFCD_G.xpt") self.file04 = os.path.join(self.dirpath, "paxraw_...
class TestXport: self.dirpath = datapath("io", "sas", "data") self.file01 = os.path.join(self.dirpath, "DEMO_G.xpt") self.file02 = os.path.join(self.dirpath, "SSHSV1_A.xpt") self.file02b = open(os.path.join(self.dirpath, "SSHSV1_A.xpt"), "rb") self.file03 = os.path.join(self.dirp...
class TestXport: data = read_sas(self.file02) tm.assert_frame_equal(data, data_csv) def test_multiple_types(self): # Test with DRXFCD_G.xpt (contains text and numeric variables)
class TestXport: data = read_sas(self.file02) tm.assert_frame_equal(data, data_csv) def test2_binary(self): # Test with SSHSV1_A.xpt, read as a binary file # Compare to this data_csv = pd.read_csv(self.file02.replace(".xpt", ".csv")) numeric_as_float(data_csv) ...
import re from io import BytesIO from waitress.compat import ( tostr, urlparse, unquote_bytes_to_wsgi, ) from waitress.buffers import OverflowableBuffer from waitress.receiver import ( FixedStreamReceiver, ChunkedReceiver, ) from waitress.utilities import ( find_double_newline, RequestEn...
import re from io import BytesIO from waitress.buffers import OverflowableBuffer from waitress.compat import tostr, unquote_bytes_to_wsgi, urlparse from waitress.receiver import ChunkedReceiver, FixedStreamReceiver from waitress.utilities import ( BadRequest, RequestEntityTooLarge, RequestHeaderFieldsTooLa...
def received(self, data): # Header finished. header_plus = s[:index] consumed = len(data) - (len(s) - index) # Remove preceeding blank lines. header_plus = header_plus.lstrip() if not header_plus: self.em...
def received(self, data): # Header finished. header_plus = s[:index] consumed = len(data) - (len(s) - index) # Remove preceeding blank lines. This is suggested by # https://tools.ietf.org/html/rfc7230#section-3.5 to support ...
def parse_header(self, header_plus): Parses the header_plus block of text (the headers plus the first line of the request). """ index = header_plus.find(b"\n") if index >= 0: first_line = header_plus[:index].rstrip() header = header_plus[index + 1 :] ...
def parse_header(self, header_plus): Parses the header_plus block of text (the headers plus the first line of the request). """ index = header_plus.find(b"\r\n") if index >= 0: first_line = header_plus[:index].rstrip() header = header_plus[index + 2 :] ...
def get_header_lines(header): Splits the header into lines, putting multi-line headers together. """ r = [] lines = header.split(b"\n") for line in lines: if line.startswith((b" ", b"\t")): if not r: # https://corte.si/posts/code/pathod/pythonservers/index.html
def get_header_lines(header): Splits the header into lines, putting multi-line headers together. """ r = [] lines = header.split(b"\r\n") for line in lines: if b"\r" in line or b"\n" in line: raise ParsingError('Bare CR or LF found in header line "%s"' % tostr(line)) if ...
"""Data Chunk Receiver """ from waitress.utilities import find_double_newline from waitress.utilities import BadRequest class FixedStreamReceiver(object):
"""Data Chunk Receiver """ from waitress.utilities import BadRequest, find_double_newline class FixedStreamReceiver(object):
def __len__(self): def received(self, data): "See IStreamConsumer" rm = self.remain if rm < 1: self.completed = True # Avoid any chance of spinning return 0 datalen = len(data) if rm <= datalen: self.buf.append(data[:rm]) self....
def __len__(self): def received(self, data): "See IStreamConsumer" rm = self.remain if rm < 1: self.completed = True # Avoid any chance of spinning return 0 datalen = len(data) if rm <= datalen: self.buf.append(data[:rm]) se...
def getbuf(self): class ChunkedReceiver(object): chunk_remainder = 0 control_line = b"" all_chunks_received = False trailer = b""
def getbuf(self): class ChunkedReceiver(object): chunk_remainder = 0 validate_chunk_end = False control_line = b"" all_chunks_received = False trailer = b""
def __len__(self): def received(self, s): # Returns the number of bytes consumed. if self.completed: return 0 orig_size = len(s) while s: rm = self.chunk_remainder if rm > 0: # Receive the remainder of a chunk. to_w...
def __len__(self): def received(self, s): # Returns the number of bytes consumed. if self.completed: return 0 orig_size = len(s) while s: rm = self.chunk_remainder if rm > 0: # Receive the remainder of a chunk. t...
def received(self, s): else: # Control line finished. line = s[:pos] s = s[pos + 1 :] self.control_line = b"" line = line.strip() if line: # Begin a new chunk. ...
def received(self, s): else: # Control line finished. line = s[:pos] s = s[pos + 2 :] self.control_line = b"" line = line.strip() if line: # Begin a new chunk....
def received(self, s): except ValueError: # garbage in input self.error = BadRequest("garbage in chunked encoding input") sz = 0 if sz > 0: # Start a new chunk. ...
def received(self, s): except ValueError: # garbage in input self.error = BadRequest("garbage in chunked encoding input") sz = 0 if sz > 0: # Start a new chunk. ...
def received(self, s): else: # Receive the trailer. trailer = self.trailer + s if trailer.startswith(b"\r\n"): # No trailer. self.completed = True return orig_size - (len(trailer) - 2) ...
def received(self, s): else: # Receive the trailer. trailer = self.trailer + s if trailer.startswith(b"\r\n"): # No trailer. self.completed = True return orig_size - (len(trailer) - 2) ...
def received(self, s): # Finished the trailer. self.completed = True self.trailer = trailer[:pos] return orig_size - (len(trailer) - pos) return orig_size def getfile(self):
def received(self, s): # Finished the trailer. self.completed = True self.trailer = trailer[:pos] return orig_size - (len(trailer) - pos) return orig_size def getfile(self):
def test_del_channel(self): def test_received(self): inst, sock, map = self._makeOneWithMap() inst.server = DummyServer() inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.server.tasks, [inst]) self.assertTrue(inst.requests)
def test_del_channel(self): def test_received(self): inst, sock, map = self._makeOneWithMap() inst.server = DummyServer() inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.server.tasks, [inst]) self.assertTrue(inst.requests)
def test_received_preq_not_completed(self): inst.request = preq preq.completed = False preq.empty = True inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.requests, ()) self.assertEqual(inst.server.tasks, [])
def test_received_preq_not_completed(self): inst.request = preq preq.completed = False preq.empty = True inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.requests, ()) self.assertEqual(inst.server.tasks, [])
def test_received_preq_completed_empty(self): inst.request = preq preq.completed = True preq.empty = True inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, None) self.assertEqual(inst.server.tasks, [])
def test_received_preq_completed_empty(self): inst.request = preq preq.completed = True preq.empty = True inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, None) self.assertEqual(inst.server.tasks, [])
def test_received_preq_error(self): inst.request = preq preq.completed = True preq.error = True inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, None) self.assertEqual(len(inst.server.tasks), 1) self.assertTrue(inst.requests)
def test_received_preq_error(self): inst.request = preq preq.completed = True preq.error = True inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, None) self.assertEqual(len(inst.server.tasks), 1) self.assertTrue(inst.requests)
def test_received_preq_completed_connection_close(self): preq.completed = True preq.empty = True preq.connection_close = True inst.received(b"GET / HTTP/1.1\n\n" + b"a" * 50000) self.assertEqual(inst.request, None) self.assertEqual(inst.server.tasks, []) def test_rec...
def test_received_preq_completed_connection_close(self): preq.completed = True preq.empty = True preq.connection_close = True inst.received(b"GET / HTTP/1.1\r\n\r\n" + b"a" * 50000) self.assertEqual(inst.request, None) self.assertEqual(inst.server.tasks, []) def test...
def test_received_headers_finished_expect_continue_false(self): preq.completed = False preq.empty = False preq.retval = 1 inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.assertEqual(inst.outbuf...
def test_received_headers_finished_expect_continue_false(self): preq.completed = False preq.empty = False preq.retval = 1 inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.assertEqual(inst.ou...
def test_received_headers_finished_expect_continue_true(self): preq.headers_finished = True preq.completed = False preq.empty = False inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.assertEqual...
def test_received_headers_finished_expect_continue_true(self): preq.headers_finished = True preq.completed = False preq.empty = False inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.assertE...
def test_received_headers_finished_expect_continue_true_sent_true(self): preq.completed = False preq.empty = False inst.sent_continue = True inst.received(b"GET / HTTP/1.1\n\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self.asse...
def test_received_headers_finished_expect_continue_true_sent_true(self): preq.completed = False preq.empty = False inst.sent_continue = True inst.received(b"GET / HTTP/1.1\r\n\r\n") self.assertEqual(inst.request, preq) self.assertEqual(inst.server.tasks, []) self....
def _read_echo(self, fp): return line, headers, echo.parse_response(body) def test_date_and_server(self): to_send = "GET / HTTP/1.0\n" "Content-Length: 0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def _read_echo(self, fp): return line, headers, echo.parse_response(body) def test_date_and_server(self): to_send = "GET / HTTP/1.0\r\nContent-Length: 0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_date_and_server(self): def test_bad_host_header(self): # https://corte.si/posts/code/pathod/pythonservers/index.html to_send = "GET / HTTP/1.0\n" " Host: 0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_date_and_server(self): def test_bad_host_header(self): # https://corte.si/posts/code/pathod/pythonservers/index.html to_send = "GET / HTTP/1.0\r\n Host: 0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_bad_host_header(self): self.assertTrue(headers.get("date")) def test_send_with_body(self): to_send = "GET / HTTP/1.0\n" "Content-Length: 5\n\n" to_send += "hello" to_send = tobytes(to_send) self.connect()
def test_bad_host_header(self): self.assertTrue(headers.get("date")) def test_send_with_body(self): to_send = "GET / HTTP/1.0\r\nContent-Length: 5\r\n\r\n" to_send += "hello" to_send = tobytes(to_send) self.connect()
def test_send_with_body(self): self.assertEqual(echo.body, b"hello") def test_send_empty_body(self): to_send = "GET / HTTP/1.0\n" "Content-Length: 0\n\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_send_with_body(self): self.assertEqual(echo.body, b"hello") def test_send_empty_body(self): to_send = "GET / HTTP/1.0\r\nContent-Length: 0\r\n\r\n" to_send = tobytes(to_send) self.connect() self.sock.send(to_send)
def test_multiple_requests_without_body(self): self.sock = orig_sock def test_without_crlf(self): data = "Echo\nthis\r\nplease" s = tobytes( "GET / HTTP/1.0\n" "Connection: close\n" "Content-Length: %d\n" "\n" "%s" % (len(data), da...
def test_multiple_requests_without_body(self): self.sock = orig_sock def test_without_crlf(self): data = "Echo\r\nthis\r\nplease" s = tobytes( "GET / HTTP/1.0\r\n" "Connection: close\r\n" "Content-Length: %d\r\n" "\r\n" "%s" % (len...
def test_large_body(self): # 1024 characters. body = "This string has 32 characters.\r\n" * 32 s = tobytes( "GET / HTTP/1.0\n" "Content-Length: %d\n" "\n" "%s" % (len(body), body) ) self.connect() self.sock.send(s)
def test_large_body(self): # 1024 characters. body = "This string has 32 characters.\r\n" * 32 s = tobytes( "GET / HTTP/1.0\r\nContent-Length: %d\r\n\r\n%s" % (len(body), body) ) self.connect() self.sock.send(s)
def test_many_clients(self): h.close() def test_chunking_request_without_content(self): header = tobytes("GET / HTTP/1.1\n" "Transfer-Encoding: chunked\n\n") self.connect() self.sock.send(header) self.sock.send(b"0\r\n\r\n")
def test_many_clients(self): h.close() def test_chunking_request_without_content(self): header = tobytes("GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n") self.connect() self.sock.send(header) self.sock.send(b"0\r\n\r\n")
def test_chunking_request_with_content(self): control_line = b"20;\r\n" # 20 hex = 32 dec s = b"This string has 32 characters.\r\n" expected = s * 12 header = tobytes("GET / HTTP/1.1\n" "Transfer-Encoding: chunked\n\n") self.connect() self.sock.send(header) fp = ...
def test_chunking_request_with_content(self): control_line = b"20;\r\n" # 20 hex = 32 dec s = b"This string has 32 characters.\r\n" expected = s * 12 header = tobytes("GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n") self.connect() self.sock.send(header) fp...
def test_chunking_request_with_content(self): def test_broken_chunked_encoding(self): control_line = "20;\r\n" # 20 hex = 32 dec s = "This string has 32 characters.\r\n" to_send = "GET / HTTP/1.1\nTransfer-Encoding: chunked\n\n" to_send += control_line + s # garbage in input...
def test_chunking_request_with_content(self): def test_broken_chunked_encoding(self): control_line = "20;\r\n" # 20 hex = 32 dec s = "This string has 32 characters.\r\n" to_send = "GET / HTTP/1.1\r\nTransfer-Encoding: chunked\r\n\r\n" to_send += control_line + s + "\r\n" # g...
def test_broken_chunked_encoding(self): self.assertline(line, "400", "Bad Request", "HTTP/1.1") cl = int(headers["content-length"]) self.assertEqual(cl, len(response_body)) self.assertEqual( sorted(headers.keys()), ["connection", "content-length", "content-type", "date", "ser...
def test_broken_chunked_encoding(self): self.assertline(line, "400", "Bad Request", "HTTP/1.1") cl = int(headers["content-length"]) self.assertEqual(cl, len(response_body)) self.assertTrue(b"Chunk not properly terminated" in response_body) self.assertEqual( sorted(hea...
def test_keepalive_http_10(self): # Handling of Keep-Alive within HTTP 1.0 data = "Default: Don't keep me alive" s = tobytes( "GET / HTTP/1.0\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) self.connect() self.sock.send(s)
def test_keepalive_http_10(self): # Handling of Keep-Alive within HTTP 1.0 data = "Default: Don't keep me alive" s = tobytes( "GET / HTTP/1.0\r\nContent-Length: %d\r\n\r\n%s" % (len(data), data) ) self.connect() self.sock.send(s)
def test_keepalive_http10_explicit(self): # the corresponding header data = "Keep me alive" s = tobytes( "GET / HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) self.connect()
def test_keepalive_http10_explicit(self): # the corresponding header data = "Keep me alive" s = tobytes( "GET / HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n" "\r\n" "%s" % (len(data), data) ) self.c...
def test_keepalive_http_11(self): # All connections are kept alive, unless stated otherwise data = "Default: Keep me alive" s = tobytes( "GET / HTTP/1.1\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) self.connect() self.sock.send(s)
def test_keepalive_http_11(self): # All connections are kept alive, unless stated otherwise data = "Default: Keep me alive" s = tobytes( "GET / HTTP/1.1\r\nContent-Length: %d\r\n\r\n%s" % (len(data), data) ) self.connect() self.sock.send(s)
def test_keepalive_http11_explicit(self): # Explicitly set keep-alive data = "Default: Keep me alive" s = tobytes( "GET / HTTP/1.1\n" "Connection: keep-alive\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) self...
def test_keepalive_http11_explicit(self): # Explicitly set keep-alive data = "Default: Keep me alive" s = tobytes( "GET / HTTP/1.1\r\n" "Connection: keep-alive\r\n" "Content-Length: %d\r\n" "\r\n" "%s" % (len(data), data) ) ...
def test_keepalive_http11_connclose(self): # specifying Connection: close explicitly data = "Don't keep me alive" s = tobytes( "GET / HTTP/1.1\n" "Connection: close\n" "Content-Length: %d\n" "\n" "%s" % (len(data), data) ) ...
def test_keepalive_http11_connclose(self): # specifying Connection: close explicitly data = "Don't keep me alive" s = tobytes( "GET / HTTP/1.1\r\n" "Connection: close\r\n" "Content-Length: %d\r\n" "\r\n" "%s" % (len(data), data) ...
def test_keepalive_http11_connclose(self): def test_proxy_headers(self): to_send = ( "GET / HTTP/1.0\n" "Content-Length: 0\n" "Host: www.google.com:8080\n" "X-Forwarded-For: 192.168.1.1\n" "X-Forwarded-Proto: https\n" "X-Forwarded-Port...
def test_keepalive_http11_connclose(self): def test_proxy_headers(self): to_send = ( "GET / HTTP/1.0\r\n" "Content-Length: 0\r\n" "Host: www.google.com:8080\r\n" "X-Forwarded-For: 192.168.1.1\r\n" "X-Forwarded-Proto: https\r\n" "X-Forw...
def test_expect_continue(self): # specifying Connection: close explicitly data = "I have expectations" to_send = tobytes( "GET / HTTP/1.1\n" "Connection: close\n" "Content-Length: %d\n" "Expect: 100-continue\n" "\n" "%s" % (...
def test_expect_continue(self): # specifying Connection: close explicitly data = "I have expectations" to_send = tobytes( "GET / HTTP/1.1\r\n" "Connection: close\r\n" "Content-Length: %d\r\n" "Expect: 100-continue\r\n" "\r\n" ...
def test_short_body(self): # check to see if server closes connection when body is too short # for cl header to_send = tobytes( "GET /short_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() ...
def test_short_body(self): # check to see if server closes connection when body is too short # for cl header to_send = tobytes( "GET /short_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connec...
def test_long_body(self): # check server doesnt close connection when body is too short # for cl header to_send = tobytes( "GET /long_body HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: 0\n" "\n" ) self.connect() se...
def test_long_body(self): # check server doesnt close connection when body is too short # for cl header to_send = tobytes( "GET /long_body HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: 0\r\n" "\r\n" ) self.connect() ...
def tearDown(self): def test_http10_generator(self): body = string.ascii_letters to_send = ( "GET / HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: %d\n\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def tearDown(self): def test_http10_generator(self): body = string.ascii_letters to_send = ( "GET / HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n\r\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def test_http10_generator(self): def test_http10_list(self): body = string.ascii_letters to_send = ( "GET /list HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: %d\n\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def test_http10_generator(self): def test_http10_list(self): body = string.ascii_letters to_send = ( "GET /list HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n\r\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def test_http10_list(self): def test_http10_listlentwo(self): body = string.ascii_letters to_send = ( "GET /list_lentwo HTTP/1.0\n" "Connection: Keep-Alive\n" "Content-Length: %d\n\n" % len(body) ) to_send += body to_send = tobytes(to_send)
def test_http10_list(self): def test_http10_listlentwo(self): body = string.ascii_letters to_send = ( "GET /list_lentwo HTTP/1.0\r\n" "Connection: Keep-Alive\r\n" "Content-Length: %d\r\n\r\n" % len(body) ) to_send += body to_send = tobytes(...
def test_http10_listlentwo(self): def test_http11_generator(self): body = string.ascii_letters to_send = "GET / HTTP/1.1\n" "Content-Length: %s\n\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http10_listlentwo(self): def test_http11_generator(self): body = string.ascii_letters to_send = "GET / HTTP/1.1\r\nContent-Length: %s\r\n\r\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http11_generator(self): def test_http11_list(self): body = string.ascii_letters to_send = "GET /list HTTP/1.1\n" "Content-Length: %d\n\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()
def test_http11_generator(self): def test_http11_list(self): body = string.ascii_letters to_send = "GET /list HTTP/1.1\r\nContent-Length: %d\r\n\r\n" % len(body) to_send += body to_send = tobytes(to_send) self.connect()