From 92da8f4795ad7f4e3c5281d748ba924b9da1cf08 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Mon, 19 Sep 2016 00:04:28 -0400 Subject: [PATCH 01/14] Revert "Fixed issues with cu_auth_weight, where file/weight strings were passed instead of integer weights." This reverts commit 4e1584b4f0883bec83779a7d541753f63f1f455e. --- gitnet/commit_log.py | 4 ++-- gitnet/helpers.py | 15 ++------------- gitnet/log.py | 22 ++++++---------------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/gitnet/commit_log.py b/gitnet/commit_log.py index 0127500..f9bf40a 100644 --- a/gitnet/commit_log.py +++ b/gitnet/commit_log.py @@ -20,7 +20,7 @@ import datetime from gitnet.log import Log from gitnet.exceptions import InputError -from gitnet.helpers import datetime_git, most_common, filter_regex, net_edges_simple, net_edges_changes, net_edges_cu_auth_changes +from gitnet.helpers import datetime_git, most_common, filter_regex, net_edges_simple, net_edges_changes class CommitLog(Log): @@ -284,7 +284,7 @@ def generate_cu_auth_changes(self): concern when generating a network with edges weighted by cu_auth_changes, in which case the network generator will check that these weight have been computed. """ - warnings.warn("generate_cu_auth_changes has only been tested informally. Proceed with caution.") + warnings.warn("generate_cu_auth_changes not yet tested. Proceed with caution.") self_copy = copy.deepcopy(self) for record in self_copy: if "files" in self_copy[record]: diff --git a/gitnet/helpers.py b/gitnet/helpers.py index 3ffdf0c..3bf8af4 100644 --- a/gitnet/helpers.py +++ b/gitnet/helpers.py @@ -16,7 +16,6 @@ import datetime as dt import re -import warnings from gitnet.exceptions import InputError # Working with Git Log date strings @@ -407,18 +406,8 @@ def net_edges_cu_auth_changes(v1, v2, record, keep): """ properties = {k:v for k,v in record.items() if k in keep} if "cu_auth_changes" in record.keys(): - cu_auth_weight = list(set([r for r in record["cu_auth_changes"] if v2 in r.split(":")])) - if len(cu_auth_weight) != 1: - warning_string = "Incorrect number of matches({}) when generating cu_auth_weights. Weight set to 1. " \ - "v1: {}, v2: {}, record: {}".format(len(cu_auth_weight),v1,v2,record["cu_auth_changes"]) - warnings.warn(warning_string) - print("CU_AUTH_CHANGES MATCHED: {}".format(cu_auth_weight)) - properties["weight"] = 1 - return (v1, v2, properties) - else: - cu_auth_weight = int(cu_auth_weight[0].split(":")[-1]) - properties["weight"] = cu_auth_weight - return (v1, v2, properties) + properties["weight"] = record["cu_auth_changes"] + return (v1, v2, properties) # Network Attribute Helper Functions def node_colours(d): diff --git a/gitnet/log.py b/gitnet/log.py index 2a71639..4d9421e 100644 --- a/gitnet/log.py +++ b/gitnet/log.py @@ -21,9 +21,8 @@ import copy import subprocess as sub from gitnet.multigraph import MultiGraphPlus -from gitnet.exceptions import InputError from gitnet.helpers import datetime_git, filter_before, filter_beforex, filter_since, filter_sincex, \ - filter_has, filter_equals, net_edges_simple, net_edges_changes, net_edges_cu_auth_changes + filter_has, filter_equals, net_edges_simple, net_edges_changes class Log(object): @@ -584,7 +583,7 @@ def vector(self, tag): # Network Generation and node and edge writing features, follow a second alpha-ordering. - def generate_edges(self, mode1, mode2, helper="net_edges_simple", edge_attributes=[]): + def generate_edges(self, mode1, mode2, helper=net_edges_simple, edge_attributes=[]): """ Generates bipartite edges present in each Log record. @@ -598,9 +597,9 @@ def generate_edges(self, mode1, mode2, helper="net_edges_simple", edge_attribute >> A record attribute or tag, which becomes the second node type. - > *helper* : `string` + > *helper* : `function` - >> The name of the function that computes the edges. Options are simple_edge (default), net_edges_cu_auth_changes and changes_edge. + >> The function that computes the edges. Options are simple_edge (default) and changes_edge. > *edge_attributes* : @@ -609,7 +608,7 @@ def generate_edges(self, mode1, mode2, helper="net_edges_simple", edge_attribute **Return** : - > A generator object which yields edges and their weights in form (v1, v2, {properties_dictionary}). + > A generator object containing edges and their weights. **Notes** : @@ -621,15 +620,6 @@ def generate_edges(self, mode1, mode2, helper="net_edges_simple", edge_attribute >> Computes edges between authors and files based on the number of lines changed in the corresponding changes (weight is 6 for `README.md | 6 +++---`). """ - helper_dict = {"net_edges_simple":net_edges_simple, - "net_edges_changes":net_edges_changes, - "net_edges_cu_auth_changes":net_edges_cu_auth_changes} - if helper in ["net_edges_changes", "net_edges_cu_auth_changes"]: - if str(type(self)) != "": - raise InputError("{} only supported for CommitLog subclass".format(helper)) - if helper == "net_edges_cu_auth_changes" and "cu_auth_changes" not in self.attributes(): - warnings.warn("Cumulative author changes must be generated before using net_edges_cu_auth_changes." - "(e.g. my_log = my_log.generate_cu_auth_changes())") for record in self.collection: cur = self.collection[record] if mode1 in cur.keys() and mode2 in cur.keys(): @@ -644,7 +634,7 @@ def generate_edges(self, mode1, mode2, helper="net_edges_simple", edge_attribute # Yield edges for item1 in m1: for item2 in m2: - yield helper_dict[helper](item1, item2, cur, edge_attributes) + yield helper(item1, item2, cur, edge_attributes) def generate_network(self, mode1, mode2, colours=None, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[], mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[]): From c6e4434ad9698faa26c724f6bc5d0f46da5934ae Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Mon, 19 Sep 2016 00:04:42 -0400 Subject: [PATCH 02/14] Revert "Implemented cu_auth_changes helper for generating edge weights. Implemented utc_date and utc_datetime attributes. Other minor changes, to warnings, todo items, and documentation." This reverts commit 580a4b17594c3949a685511f624a38e5ac6bddfb. --- gitnet/__init__.py | 2 +- gitnet/commit_log.py | 75 ++------------------------------------------ gitnet/helpers.py | 32 +------------------ gitnet/log.py | 10 ------ gitnet/multigraph.py | 2 -- 5 files changed, 5 insertions(+), 116 deletions(-) diff --git a/gitnet/__init__.py b/gitnet/__init__.py index a6a5b20..28bb8a1 100644 --- a/gitnet/__init__.py +++ b/gitnet/__init__.py @@ -18,5 +18,5 @@ from .exceptions import RepositoryError, ParseError, InputError from .log import Log from .commit_log import CommitLog -from .helpers import net_edges_simple, net_edges_changes, net_edges_cu_auth_changes, node_colours +from .helpers import net_edges_simple, net_edges_changes, node_colours from .multigraph import MultiGraphPlus diff --git a/gitnet/commit_log.py b/gitnet/commit_log.py index f9bf40a..b3cac1c 100644 --- a/gitnet/commit_log.py +++ b/gitnet/commit_log.py @@ -14,10 +14,8 @@ # If not, see . # ********************************************************************************************* -import copy import numpy as np -import warnings -import datetime +import copy from gitnet.log import Log from gitnet.exceptions import InputError from gitnet.helpers import datetime_git, most_common, filter_regex, net_edges_simple, net_edges_changes @@ -28,24 +26,6 @@ class CommitLog(Log): A subclass of `Log` for holding git commit logs, whose data has been parsed into a dictionary of dictionaries. """ - def annotate(self): - """ - A method that automatically runs after initialization. Processes date information, and adds easily parsed - date strings to each record. - - utc_date : "YYYY-MM-DD" in Coordinated Universal Time. Formatted for `parse_date()` in `readr` package in R. - utc_datetime : A standardized date string in Coordinated Universal Time - """ - warnings.warn("New utc_date and utc_datetime attributes have only been tested informally.") - for record in self: - if "date" in self[record]: - git_dt = datetime_git(self[record]["date"]).astimezone(datetime.timezone(datetime.timedelta(0))) - self[record]["utc_date"] = git_dt.strftime("%Y-%m-%d") - self[record]["utc_datetime"] = git_dt.strftime("%Y-%m-%d %H:%M:%S") - else: - self[record]["utc_date"] = None - self[record]["utc_datetime"] = None - def describe(self, mode = "default", exclude = []): """ A method for creating extended descriptive output for the `Commitlog` subclass. @@ -195,8 +175,8 @@ def get_tags(self): > A list of ordered reference hashes. """ - return ["hash","author","email","date","utc_date","utc_datetime","mode","merge", - "summary","fedits","inserts","deletes","message","files","changes"] + return ["hash","author","email","date","mode","merge","summary", + "fedits","inserts","deletes","message","files","changes"] def ignore(self, pattern, ignoreif="match"): """ @@ -274,52 +254,3 @@ def network(self, type): edge_helper=net_edges_changes) else: raise InputError("{} is not a valid network preset.".format(type)) - - def generate_cu_auth_changes(self): - """ - Generates a new tag called "cu_auth_changes"; for each commit, cu_auth_changes is the cumulative changes that - the commit's author has made to each file. The new tag is a list of strings in the format "filename:weight". - This tag is currently not implemented as a default option (i.e. computed upon the initialization of a commit_log - object) because it is relatively inefficient, and important only in specific types of analysis. It is of main - concern when generating a network with edges weighted by cu_auth_changes, in which case the network generator - will check that these weight have been computed. - """ - warnings.warn("generate_cu_auth_changes not yet tested. Proceed with caution.") - self_copy = copy.deepcopy(self) - for record in self_copy: - if "files" in self_copy[record]: - date = self_copy[record]["date"] - cu_log = self_copy.filter("date","before",date) - cu_auth_log = cu_log.filter("author","equals",self_copy[record]["author"]) - cu_auth_dict = {} - cu_auth_changes = [] - for ch in cu_auth_log.vector("changes"): - split_change = ch.split("|") - if split_change == [""]: - break - # Get the file name - fname = split_change[0].replace(" ", "") - # Get the number of changes - weight_str = split_change[1] - if "Bin" in weight_str: - weight = 1 - else: - weight = "" - for char in weight_str: - if char.isnumeric(): - weight += char - if weight == "": - weight = "0" - weight = int(weight) - if fname in cu_auth_dict.keys(): - cu_auth_dict[fname] += weight - else: - cu_auth_dict[fname] = weight - for file in self_copy[record]["files"]: - if file in cu_auth_dict: - cu_auth_changes.append("{}:{}".format(file,cu_auth_dict[file])) - self_copy[record]["cu_auth_changes"] = cu_auth_changes - return self_copy - - - diff --git a/gitnet/helpers.py b/gitnet/helpers.py index 3bf8af4..180c1c3 100644 --- a/gitnet/helpers.py +++ b/gitnet/helpers.py @@ -47,7 +47,7 @@ def datetime_reference(s): if type(s) is dt.datetime: ref_date = s elif type(s) is str: - git_date_p = re.compile("[A-Z][a-z][a-z] [A-Z][a-z][a-z] \d\d? \d\d:\d\d:\d\d \d{4} [-+]\d{4}") + git_date_p = re.compile("[A-Z][a-z][a-z] [A-Z][a-z][a-z] \d\d? \d\d:\d\d:\d\d \d{4} -\d{4}") if bool(re.match(git_date_p, s)): ref_date = datetime_git(s) else: @@ -379,36 +379,6 @@ def net_edges_changes(v1, v2, record, keep): properties["weight"] = int(weight) return (v1, v2, properties) -def net_edges_cu_auth_changes(v1, v2, record, keep): - """ - A helper function for the Log.generate_edges() method. Network must be a bipartite author-file network. Creates an - edge between two vertices, weighted by the total number of changes this author has made to this file, up to and - including this commit (but not later commits). The first vertex (`v1`) must have the type "author". The second - vertex (`v2`) must have the type "files". - - **Parameters** - - >*v1* : `any` - >> The first vertex, whose type must be "author". - - >*v2* : `str` - >> A string giving the id of a vertex whose type is "files". - - >*record* : `str` - >> The short hash string for the current record in edge generation. - - >*keep* : `list` - >> A list of edge attributes to be kept from the CommitLog record. - - **Return** - > A tuple, in the format (id1, id2, {edge attribute dictionary}), representing an edge between `v1` and `v2`. The - edge attribute dictionary will contain a weight attribute, determined by the number of lines changed in `v2`. - """ - properties = {k:v for k,v in record.items() if k in keep} - if "cu_auth_changes" in record.keys(): - properties["weight"] = record["cu_auth_changes"] - return (v1, v2, properties) - # Network Attribute Helper Functions def node_colours(d): """ diff --git a/gitnet/log.py b/gitnet/log.py index 4d9421e..12ce470 100644 --- a/gitnet/log.py +++ b/gitnet/log.py @@ -72,7 +72,6 @@ def __init__(self, dofd={}, source=None, path=None, key_type=None, filters=[]): self.key_type = key_type self.filters = filters # This must be updated as tags/subclasses are added. Ideally, this would be housed within each subclass. - self.annotate() self.tags = self.get_tags() def __iter__(self): @@ -108,13 +107,6 @@ def __str__(self): return "Log containing {} records from {} created at {}."\ .format(len(self.collection), self.source, self.timestamp) - def annotate(self): - """ - A method that automatically runs after initialization. Used to define additional initialization behaviours in - Log subclasses. - """ - pass - def attributes(self): """ A method for determining what data has been recorded in this `Commitlog`. @@ -145,7 +137,6 @@ def attributes(self): return attr_list def author_email_list(self): - #TODO: I think that this should be in commit_log. It is commit_log specific, not "log-general". """ Gathers each unique author email combination from the log, and then prints them in a list. The intention is that the user can use these author names in the `replace_val` function. @@ -211,7 +202,6 @@ def describe(self): return description def detect_dup_emails(self): - ## TODO: Same here. Do we want this for all Logs ever??? """ Finds emails which are associated with multiple authors. This list should be a good indicator of authors which have committed under multiple names. This will allow you to either replace the author names in the `Log`, or diff --git a/gitnet/multigraph.py b/gitnet/multigraph.py index 238c153..c0bbfd7 100644 --- a/gitnet/multigraph.py +++ b/gitnet/multigraph.py @@ -312,8 +312,6 @@ def quickplot(self, fname, k="4/sqrt(n)", iterations=50, layout="neato", size=20 # Plot the network print("Plotting...") if layout in ["dot", "neato", "fdp", "circo"]: - warnings.warn("Because of outstanding issues in the source package, graphviz layouts" - "don't work on some computers.") nx.draw(copy_net, pos=graphviz_layout(copy_net, prog=layout), node_size=size, From 31caee8f94da0ebddf8c18e0e0cf9c2a8a6c5958 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Mon, 19 Sep 2016 21:35:51 -0400 Subject: [PATCH 03/14] Added and tested log.add_attribute method for adding new properties to log records. --- gitnet/gitnet_tests/test_log.py | 33 +++++++++++++++++++++++++++++++++ gitnet/log.py | 23 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/gitnet/gitnet_tests/test_log.py b/gitnet/gitnet_tests/test_log.py index 5927523..10f7749 100644 --- a/gitnet/gitnet_tests/test_log.py +++ b/gitnet/gitnet_tests/test_log.py @@ -102,6 +102,39 @@ def test_commit_log_values(self): # Delete the temporary .git folder sub.call(["rm", "-rf", ".git"]) +class AddAttributeTest(unittest.TestCase): + """ + Tests for the add_attribute method. + """ + def setUp(self): + data = {"Bob": {"author": 'Bob', + "email": 'bob@gmail.com', + "type": 'author', + "loc": 'Waterloo', + "books": ['BookA', 'BookB']}, + "Bobby": {"author": 'Bobby', + "email": 'bobby@gmail.com', + "type": 'author', + "loc": 'Kitchener', + "books": ['BookC', 'BookD']}, + "Robert": {"author": 'Robert', + "email": 'robby@gmail.com', + "type": 'author', + "loc": 'Kitchener', + "books": ['BookC', 'BookD']}} + self.log = gitnet.Log(data) + + def test_new_attr_1(self): + new_log = self.log.add_attribute("letter", lambda d: d["author"][0]) + self.assertEqual(new_log["Bob"]["letter"], "B") + self.assertEqual(new_log["Bobby"]["letter"], "B") + self.assertEqual(new_log["Robert"]["letter"], "R") + + def test_new_attr_1(self): + new_log = self.log.add_attribute("edge",lambda d: gitnet.net_edges_simple("v1","v2",d,["loc"])) + self.assertEqual(new_log["Bob"]["edge"], ("v1","v2",{"loc":"Waterloo"})) + self.assertEqual(new_log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"})) + self.assertEqual(new_log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"})) class DescribeTests(unittest.TestCase): def setUp(self): diff --git a/gitnet/log.py b/gitnet/log.py index 12ce470..799bd85 100644 --- a/gitnet/log.py +++ b/gitnet/log.py @@ -136,6 +136,29 @@ def attributes(self): attr_list = attr_list + sorted(list(attr)) return attr_list + def add_attribute(self,name,helper): + """ + Creates a new record attribute. + + **Parameters** : + + > *name* : `string` + + >> The name of the new attribute. + + > *helper* : `None` + + >> A helper function, which takes an attribute dict and produces the new attribute. + + **Return** : + + > A new Log object, identical to self but with the desired attribute. + """ + self_copy = copy.deepcopy(self) + for n in self_copy: + self_copy[n][name] = helper(self_copy[n]) + return self_copy + def author_email_list(self): """ Gathers each unique author email combination from the log, and then prints them in a list. From d93063543dc0250284a9a2e435977fb7acc123c1 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Mon, 19 Sep 2016 23:14:44 -0400 Subject: [PATCH 04/14] Complemented add_attribute with mutate_attribute. Added utc_date and utc_datetime attributes to CommitLog, generated upon initialization by annotate() method. Added helper functions for utc time. Wrote tests for all of the above. --- gitnet/commit_log.py | 15 ++++++++-- gitnet/gitnet_tests/test_commit_log.py | 28 ++++++++++++++++-- gitnet/gitnet_tests/test_get.py | 2 +- gitnet/gitnet_tests/test_helpers.py | 25 ++++++++++++++++ gitnet/gitnet_tests/test_log.py | 14 ++++++++- gitnet/helpers.py | 41 ++++++++++++++++++++++++++ gitnet/log.py | 30 ++++++++++++++++++- 7 files changed, 148 insertions(+), 7 deletions(-) diff --git a/gitnet/commit_log.py b/gitnet/commit_log.py index b3cac1c..8d73c88 100644 --- a/gitnet/commit_log.py +++ b/gitnet/commit_log.py @@ -18,7 +18,8 @@ import copy from gitnet.log import Log from gitnet.exceptions import InputError -from gitnet.helpers import datetime_git, most_common, filter_regex, net_edges_simple, net_edges_changes +from gitnet.helpers import datetime_git, most_common, filter_regex, net_edges_simple, net_edges_changes, \ + make_utc_datetime, make_utc_date class CommitLog(Log): @@ -26,6 +27,16 @@ class CommitLog(Log): A subclass of `Log` for holding git commit logs, whose data has been parsed into a dictionary of dictionaries. """ + def annotate(self): + """ + A method that automatically runs after initialization. Processes date information, and adds easily parsed + date strings to each record. + utc_date : "YYYY-MM-DD" in Coordinated Universal Time. Formatted for `parse_date()` in `readr` package in R. + utc_datetime : "YYYY-MM-DD HH:MM:SS" in Coordinated Universal Time. + """ + self.mutate_attribute("utc_date",make_utc_date) + self.mutate_attribute("utc_datetime",make_utc_datetime) + def describe(self, mode = "default", exclude = []): """ A method for creating extended descriptive output for the `Commitlog` subclass. @@ -175,7 +186,7 @@ def get_tags(self): > A list of ordered reference hashes. """ - return ["hash","author","email","date","mode","merge","summary", + return ["hash","author","email","date","utc_date","utc_datetime","mode","merge","summary", "fedits","inserts","deletes","message","files","changes"] def ignore(self, pattern, ignoreif="match"): diff --git a/gitnet/gitnet_tests/test_commit_log.py b/gitnet/gitnet_tests/test_commit_log.py index f16d21e..ec6065c 100644 --- a/gitnet/gitnet_tests/test_commit_log.py +++ b/gitnet/gitnet_tests/test_commit_log.py @@ -33,12 +33,36 @@ def test_basic(self): tags = my_log.get_tags() - self.assertListEqual(tags, ["hash", "author", "email", "date", "mode", "merge", "summary", - "fedits", "inserts", "deletes", "message", "files", "changes"]) + self.assertListEqual(tags, ["hash", "author", "email", "date", "utc_date", "utc_datetime", "mode", "merge", + "summary", "fedits", "inserts", "deletes", "message", "files", "changes"]) # Delete temporary .git file sub.call(["rm", "-rf", ".git"]) +class AnnotateTests(unittest.TestCase): + def setUp(self): + # Set up small network + sub.call(["cp", "-R", "small_network_repo.git", ".git"]) + path = os.getcwd() + self.my_log = gitnet.get_log(path) + + def test_utc_date(self): + """Is utc_date being generated correctly?""" + self.assertEqual(self.my_log["7965e62"]["utc_date"],"2016-05-26") + self.assertEqual(self.my_log["6cd4bbf"]["utc_date"],"2016-05-25") + self.assertEqual(self.my_log["ee2c408"]["utc_date"],"2016-05-23") + self.assertEqual(self.my_log["b3a4bac"]["utc_date"],"2016-05-20") + + def test_utc_datetime(self): + """Is utc_datetime being generated correctly?""" + self.assertEqual(self.my_log["7965e62"]["utc_datetime"],"2016-05-26 15:21:03") + self.assertEqual(self.my_log["6cd4bbf"]["utc_datetime"],"2016-05-25 05:12:48") + self.assertEqual(self.my_log["ee2c408"]["utc_datetime"],"2016-05-23 06:45:25") + self.assertEqual(self.my_log["b3a4bac"]["utc_datetime"],"2016-05-20 13:19:20") + + def tearDown(self): + # Delete temporary .git file + sub.call(["rm", "-rf", ".git"]) class DescribeTests(unittest.TestCase): def setUp(self): diff --git a/gitnet/gitnet_tests/test_get.py b/gitnet/gitnet_tests/test_get.py index f7e466f..6d89a60 100644 --- a/gitnet/gitnet_tests/test_get.py +++ b/gitnet/gitnet_tests/test_get.py @@ -97,7 +97,7 @@ def test_big_tsv(self): f = open("nx_test.tsv", "r") nx_lines = f.readlines() self.assertEqual(len(nx_lines), 4882) - self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildatemodemergesummaryfedits" + self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildateutc_dateutc_datetimemodemergesummaryfedits" "insertsdeletesmessagefileschanges") f.close() sub.call(["rm", "-rf", "nx_test.tsv"]) diff --git a/gitnet/gitnet_tests/test_helpers.py b/gitnet/gitnet_tests/test_helpers.py index 1f3ec48..bd409a6 100644 --- a/gitnet/gitnet_tests/test_helpers.py +++ b/gitnet/gitnet_tests/test_helpers.py @@ -336,5 +336,30 @@ def test_not_aorf(self): self.assertEqual(res, "lightgrey") +class TestAnnotateHelpers(unittest.TestCase): + + def test_make_utc_date(self): + """Is the function converting the string properly?""" + utc = helpers.make_utc_date({"date":"Mon Jul 22 11:40:03 2013 -0600"}) + self.assertEquals(utc, "2013-07-22") + utc = helpers.make_utc_date({"date":"Sat Apr 16 22:29:50 2016 -0200"}) + self.assertEquals(utc, "2016-04-17") + utc = helpers.make_utc_date({"date":"Fri Oct 5 12:20:15 2012 +0200"}) + self.assertEquals(utc, "2012-10-05") + utc = helpers.make_utc_date({"not":"Fri Oct 5 12:20:15 2012 +0200"}) + self.assertEquals(utc, None) + + + def test_make_utc_datetime(self): + """Is the function converting the string properly?""" + utc = helpers.make_utc_datetime({"date":"Mon Jul 22 11:40:03 2013 -0600"}) + self.assertEquals(utc, "2013-07-22 17:40:03") + utc = helpers.make_utc_datetime({"date":"Sat Apr 16 22:29:50 2016 -0200"}) + self.assertEquals(utc, "2016-04-17 00:29:50") + utc = helpers.make_utc_datetime({"date":"Fri Oct 5 12:20:15 2012 +0200"}) + self.assertEquals(utc, "2012-10-05 10:20:15") + utc = helpers.make_utc_datetime({"not":"Fri Oct 5 12:20:15 2012 +0200"}) + self.assertEquals(utc, None) + if __name__ == '__main__': unittest.main(buffer=True) diff --git a/gitnet/gitnet_tests/test_log.py b/gitnet/gitnet_tests/test_log.py index 10f7749..026c3a0 100644 --- a/gitnet/gitnet_tests/test_log.py +++ b/gitnet/gitnet_tests/test_log.py @@ -95,7 +95,7 @@ def test_commit_log_values(self): cl = gitnet.get_log(path) attr_list = cl.attributes() - exp_attr_list = {"hash","author","email","date","mode","summary", + exp_attr_list = {"hash","author","email","date","utc_date","utc_datetime","mode","summary", "fedits","inserts","message","files","changes"} self.assertSetEqual(set(attr_list), exp_attr_list) @@ -136,6 +136,18 @@ def test_new_attr_1(self): self.assertEqual(new_log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"})) self.assertEqual(new_log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"})) + def test_new_attr_mutate_1(self): + self.log.mutate_attribute("letter", lambda d: d["author"][0]) + self.assertEqual(self.log["Bob"]["letter"], "B") + self.assertEqual(self.log["Bobby"]["letter"], "B") + self.assertEqual(self.log["Robert"]["letter"], "R") + + def test_new_attr_mutate_2(self): + self.log.mutate_attribute("edge",lambda d: gitnet.net_edges_simple("v1","v2",d,["loc"])) + self.assertEqual(self.log["Bob"]["edge"], ("v1","v2",{"loc":"Waterloo"})) + self.assertEqual(self.log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"})) + self.assertEqual(self.log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"})) + class DescribeTests(unittest.TestCase): def setUp(self): data = {"Alice": {"email": 'alice@gmail.com', diff --git a/gitnet/helpers.py b/gitnet/helpers.py index 180c1c3..7c58302 100644 --- a/gitnet/helpers.py +++ b/gitnet/helpers.py @@ -415,3 +415,44 @@ def node_colours(d): return "lightgrey" else: return "lightgrey" + +# Helpers for making UTC time strings from git time strings. + +def make_utc_date(dict): + """ + Takes an attribute dictionary. If "date" present, returns "YYYY-MM-DD" in Coordinated Universal Time. + Otherwise, returns None. "date" must be a git-formatted string, e.g. 'Mon Apr 18 00:59:02 2016 -0400'. + + **Parameters**: + + > *dict* : `dict` + + >> An attribute dictionary. + + **Return** `string` or `none` + """ + if "date" in dict: + git_dt = datetime_git(dict["date"]).astimezone(dt.timezone(dt.timedelta(0))) + return git_dt.strftime("%Y-%m-%d") + else: + return None + +def make_utc_datetime(dict): + """ + Takes an attribute dictionary. If "date" present, returns "YYYY-MM-DD HH:MM:SS" in + Coordinated Universal Time. Otherwise, returns None. "date" must be a git-formatted string, + e.g. 'Mon Apr 18 00:59:02 2016 -0400'. + + **Parameters**: + + > *dict* : `dict` + + >> An attribute dictionary. + + **Return** `string` or `none` + """ + if "date" in dict: + git_dt = datetime_git(dict["date"]).astimezone(dt.timezone(dt.timedelta(0))) + return git_dt.strftime("%Y-%m-%d %H:%M:%S") + else: + return None \ No newline at end of file diff --git a/gitnet/log.py b/gitnet/log.py index 799bd85..9bc2ee6 100644 --- a/gitnet/log.py +++ b/gitnet/log.py @@ -71,7 +71,8 @@ def __init__(self, dofd={}, source=None, path=None, key_type=None, filters=[]): self.path = path self.key_type = key_type self.filters = filters - # This must be updated as tags/subclasses are added. Ideally, this would be housed within each subclass. + # Annotate and tags must be updated as tags/subclasses are added. + self.annotate() self.tags = self.get_tags() def __iter__(self): @@ -107,6 +108,12 @@ def __str__(self): return "Log containing {} records from {} created at {}."\ .format(len(self.collection), self.source, self.timestamp) + def annotate(self): + """ + A method that automatically runs after initialization. Behaviours only defined for Log subclasses. + """ + pass + def attributes(self): """ A method for determining what data has been recorded in this `Commitlog`. @@ -159,6 +166,27 @@ def add_attribute(self,name,helper): self_copy[n][name] = helper(self_copy[n]) return self_copy + def mutate_attribute(self,name,helper): + """ + Creates a new record attribute, mutating the original log. + + **Parameters** : + + > *name* : `string` + + >> The name of the new attribute. + + > *helper* : `None` + + >> A helper function, which takes an attribute dict and produces the new attribute. + + **Return** : + + > None + """ + for n in self: + self[n][name] = helper(self[n]) + def author_email_list(self): """ Gathers each unique author email combination from the log, and then prints them in a list. From 7f2ec9dc2adadbe724fb7bed597f21734da228f1 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Mon, 19 Sep 2016 23:46:39 -0400 Subject: [PATCH 05/14] =?UTF-8?q?Added=20domain=20attribute,=20created=20d?= =?UTF-8?q?uring=20annotation,=20for=20commitlog.=20Also=20tests.=20Some?= =?UTF-8?q?=20describe()=20tests=20are=20breaking=20=E2=80=94=20I=20decide?= =?UTF-8?q?d=20to=20commit=20anyway=20since=20this=20is=20a=20time=20sensi?= =?UTF-8?q?tive=20feature.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gitnet/commit_log.py | 9 +++++---- gitnet/gitnet_tests/test_commit_log.py | 9 ++++++++- gitnet/gitnet_tests/test_get.py | 2 +- gitnet/gitnet_tests/test_helpers.py | 7 ++++++- gitnet/gitnet_tests/test_log.py | 2 +- gitnet/helpers.py | 23 +++++++++++++++++++++++ 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/gitnet/commit_log.py b/gitnet/commit_log.py index 8d73c88..42eb476 100644 --- a/gitnet/commit_log.py +++ b/gitnet/commit_log.py @@ -19,7 +19,7 @@ from gitnet.log import Log from gitnet.exceptions import InputError from gitnet.helpers import datetime_git, most_common, filter_regex, net_edges_simple, net_edges_changes, \ - make_utc_datetime, make_utc_date + make_utc_datetime, make_utc_date, make_domain class CommitLog(Log): @@ -36,6 +36,7 @@ def annotate(self): """ self.mutate_attribute("utc_date",make_utc_date) self.mutate_attribute("utc_datetime",make_utc_datetime) + self.mutate_attribute("domain",make_domain) def describe(self, mode = "default", exclude = []): """ @@ -73,10 +74,10 @@ def describe(self, mode = "default", exclude = []): # Define included/excluded data summaries. if mode == "default": output = ["summary", "path", "filters", "authors", "files", - "emails", "dates", "changes", "merges", "errors"] + "emails", "domain", "date", "utc_date", "utc_datetime", "changes", "merges", "errors"] else: output = ["summary", "path", "filters", "authors", "files", - "emails", "dates", "changes", "merges", "errors"] + "emails", "domain", "date", "utc_date", "utc_datetime", "changes", "merges", "errors"] for i in exclude: output.remove(i) # Print summary @@ -186,7 +187,7 @@ def get_tags(self): > A list of ordered reference hashes. """ - return ["hash","author","email","date","utc_date","utc_datetime","mode","merge","summary", + return ["hash","author","email","domain","date","utc_date","utc_datetime","mode","merge","summary", "fedits","inserts","deletes","message","files","changes"] def ignore(self, pattern, ignoreif="match"): diff --git a/gitnet/gitnet_tests/test_commit_log.py b/gitnet/gitnet_tests/test_commit_log.py index ec6065c..5a7ea02 100644 --- a/gitnet/gitnet_tests/test_commit_log.py +++ b/gitnet/gitnet_tests/test_commit_log.py @@ -33,7 +33,7 @@ def test_basic(self): tags = my_log.get_tags() - self.assertListEqual(tags, ["hash", "author", "email", "date", "utc_date", "utc_datetime", "mode", "merge", + self.assertListEqual(tags, ["hash", "author", "email", "domain", "date", "utc_date", "utc_datetime", "mode", "merge", "summary", "fedits", "inserts", "deletes", "message", "files", "changes"]) # Delete temporary .git file @@ -60,6 +60,13 @@ def test_utc_datetime(self): self.assertEqual(self.my_log["ee2c408"]["utc_datetime"],"2016-05-23 06:45:25") self.assertEqual(self.my_log["b3a4bac"]["utc_datetime"],"2016-05-20 13:19:20") + def test_domain(self): + """Is domain being generated correctly?""" + self.assertEqual(self.my_log["7965e62"]["domain"],"gmail") + self.assertEqual(self.my_log["6cd4bbf"]["domain"],"gmail") + self.assertEqual(self.my_log["ee2c408"]["domain"],"gmail") + self.assertEqual(self.my_log["b3a4bac"]["domain"],"gmail") + def tearDown(self): # Delete temporary .git file sub.call(["rm", "-rf", ".git"]) diff --git a/gitnet/gitnet_tests/test_get.py b/gitnet/gitnet_tests/test_get.py index 6d89a60..dcbe661 100644 --- a/gitnet/gitnet_tests/test_get.py +++ b/gitnet/gitnet_tests/test_get.py @@ -97,7 +97,7 @@ def test_big_tsv(self): f = open("nx_test.tsv", "r") nx_lines = f.readlines() self.assertEqual(len(nx_lines), 4882) - self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildateutc_dateutc_datetimemodemergesummaryfedits" + self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildomaindateutc_dateutc_datetimemodemergesummaryfedits" "insertsdeletesmessagefileschanges") f.close() sub.call(["rm", "-rf", "nx_test.tsv"]) diff --git a/gitnet/gitnet_tests/test_helpers.py b/gitnet/gitnet_tests/test_helpers.py index bd409a6..bbb4245 100644 --- a/gitnet/gitnet_tests/test_helpers.py +++ b/gitnet/gitnet_tests/test_helpers.py @@ -349,7 +349,6 @@ def test_make_utc_date(self): utc = helpers.make_utc_date({"not":"Fri Oct 5 12:20:15 2012 +0200"}) self.assertEquals(utc, None) - def test_make_utc_datetime(self): """Is the function converting the string properly?""" utc = helpers.make_utc_datetime({"date":"Mon Jul 22 11:40:03 2013 -0600"}) @@ -361,5 +360,11 @@ def test_make_utc_datetime(self): utc = helpers.make_utc_datetime({"not":"Fri Oct 5 12:20:15 2012 +0200"}) self.assertEquals(utc, None) + def test_make_domain(self): + self.assertEquals(helpers.make_domain({"email":"mail@hoolagin.com"}), "hoolagin") + self.assertEquals(helpers.make_domain({"email":"joe@gmail.com"}), "gmail") + self.assertEquals(helpers.make_domain({"email":"afsjkl@gar.net"}), "gar") + self.assertEquals(helpers.make_domain({"email":"linux@cs.uwaterloo.ca"}), "cs.uwaterloo") + if __name__ == '__main__': unittest.main(buffer=True) diff --git a/gitnet/gitnet_tests/test_log.py b/gitnet/gitnet_tests/test_log.py index 026c3a0..59cf2d9 100644 --- a/gitnet/gitnet_tests/test_log.py +++ b/gitnet/gitnet_tests/test_log.py @@ -95,7 +95,7 @@ def test_commit_log_values(self): cl = gitnet.get_log(path) attr_list = cl.attributes() - exp_attr_list = {"hash","author","email","date","utc_date","utc_datetime","mode","summary", + exp_attr_list = {"hash","author","email","domain","date","utc_date","utc_datetime","mode","summary", "fedits","inserts","message","files","changes"} self.assertSetEqual(set(attr_list), exp_attr_list) diff --git a/gitnet/helpers.py b/gitnet/helpers.py index 7c58302..f2ab68c 100644 --- a/gitnet/helpers.py +++ b/gitnet/helpers.py @@ -454,5 +454,28 @@ def make_utc_datetime(dict): if "date" in dict: git_dt = datetime_git(dict["date"]).astimezone(dt.timezone(dt.timedelta(0))) return git_dt.strftime("%Y-%m-%d %H:%M:%S") + else: + return None + +def make_domain(dict): + """ + Takes an attribute dictionary. If "email" present, returns its domain. Otherwise, returns None. + + **Parameters**: + + > *dict* : `dict` + + >> An attribute dictionary. + + **Return** `string` or `none` + """ + if "email" in dict: + domain = dict["email"].split("@")[1] + go = True + while go: + if domain[-1] == ".": + go = False + domain = domain[:-1] + return domain else: return None \ No newline at end of file From 90af88b01aa2b4ee38a0ee48fe06c21d1c70977b Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Mon, 26 Sep 2016 18:23:18 -0400 Subject: [PATCH 06/14] Added error handling to domain generator. --- gitnet/gitnet_tests/test_helpers.py | 4 ++++ gitnet/helpers.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/gitnet/gitnet_tests/test_helpers.py b/gitnet/gitnet_tests/test_helpers.py index bbb4245..8590194 100644 --- a/gitnet/gitnet_tests/test_helpers.py +++ b/gitnet/gitnet_tests/test_helpers.py @@ -365,6 +365,10 @@ def test_make_domain(self): self.assertEquals(helpers.make_domain({"email":"joe@gmail.com"}), "gmail") self.assertEquals(helpers.make_domain({"email":"afsjkl@gar.net"}), "gar") self.assertEquals(helpers.make_domain({"email":"linux@cs.uwaterloo.ca"}), "cs.uwaterloo") + self.assertEquals(helpers.make_domain({"notemail":"mail@hoolagin.com"}), None) + self.assertEquals(helpers.make_domain({"email":"mailhoolagin.com"}), None) + self.assertEquals(helpers.make_domain({"email":"mail@hoolagincom"}), None) + self.assertEquals(helpers.make_domain({"email":"mail@.com"}), None) if __name__ == '__main__': unittest.main(buffer=True) diff --git a/gitnet/helpers.py b/gitnet/helpers.py index f2ab68c..06d85be 100644 --- a/gitnet/helpers.py +++ b/gitnet/helpers.py @@ -469,7 +469,13 @@ def make_domain(dict): **Return** `string` or `none` """ + # Check if email is in the data dictionary. if "email" in dict: + # Handling invalid emails. Check if the string is valid format with regex. + email_re = re.compile(".+@.+\..+") + if not re.match(email_re,dict["email"]): + return None + # Handling valid emails by stripping away non-domain characters. domain = dict["email"].split("@")[1] go = True while go: @@ -477,5 +483,6 @@ def make_domain(dict): go = False domain = domain[:-1] return domain + # If missing, produce none. else: return None \ No newline at end of file From 48949f5ebd435e1b8124f7a77008888ed8ffe5a0 Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Wed, 12 Oct 2016 16:52:40 -0400 Subject: [PATCH 07/14] Expanded error handling for make_domain helper function. Now handles None and empty string email values. Will also autmatically assign None if an error is encountered while handling the email, printing an informative warning message. --- gitnet/gitnet_tests/nx_test.tsv | 142 ++++++++++++++++++++++++++++ gitnet/gitnet_tests/test_helpers.py | 34 +++---- gitnet/helpers.py | 31 +++--- 3 files changed, 179 insertions(+), 28 deletions(-) create mode 100644 gitnet/gitnet_tests/nx_test.tsv diff --git a/gitnet/gitnet_tests/nx_test.tsv b/gitnet/gitnet_tests/nx_test.tsv new file mode 100644 index 0000000..9d01a60 --- /dev/null +++ b/gitnet/gitnet_tests/nx_test.tsv @@ -0,0 +1,142 @@ +hash author email domain date utc_date utc_datetime mode merge summary fedits inserts deletes message files changes +c43163f3dde6da4dda690da96960046b7d49275c Jeffrey Finkelstein jeffrey.finkelstein@gmail.com gmail Sun May 3 15:17:22 2015 -0400 2015-05-03 2015-05-03 19:17:22 stat 1 file changed, 31 insertions(+), 35 deletions(-) 1 31 35 Simplifies some functions in random_graphs.py networkx/generators/random_graphs.py networkx/generators/random_graphs.py | 66 +++++++++++++++++------------------- +668e812ca78cba75eb2cc0cc678195a968d07c55 Jamal jamalsenouci@gmail.com gmail Tue Nov 25 12:04:27 2014 +0000 2014-11-25 2014-11-25 12:04:27 stat 1 file changed, 2 insertions(+), 2 deletions(-) 1 2 2 added pandas to travis.yml .travis.yml .travis.yml | 4 ++-- +731554489fe9a7789e6aa3eb3a1c0f9082459d21 dschult none@none None Tue Aug 11 21:00:53 2009 +0000 2009-08-11 2009-08-11 21:00:53 stat 4 files changed, 180 insertions(+), 92 deletions(-) 4 180 92 Remove path_graph and complete_graph from docstrings in base classes in favor of G.add_path() to unify the docstrings a little. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401368 networkx/classes/digraph.py;networkx/classes/graph.py;networkx/classes/multidigraph.py;networkx/classes/multigraph.py networkx/classes/digraph.py | 61 +++++++++++-------;networkx/classes/graph.py | 133 ++++++++++++++++++++++++---------------;networkx/classes/multidigraph.py | 40 ++++++++++--;networkx/classes/multigraph.py | 38 ++++++----- +37e0f1d5dbe54805fd12bc572f41c7cc3bec122a Dan Schult dschult@colgate.edu colgate Fri Oct 2 22:50:39 2015 -0400 2015-10-03 2015-10-03 02:50:39 stat e126099 70c826b Merge pull request #1788 from networkx/dschult-patch-1 Clarify docstring and return code for _djikstra() +9720f297f80f7abf3cacfba96b2f606678257251 Chris Ellison cellison@cse.ucdavis.edu cse.ucdavis Tue Oct 5 12:56:18 2010 -0700 2010-10-05 2010-10-05 19:56:18 stat 1 file changed, 13 insertions(+), 5 deletions(-) 1 13 5 Couple errors with imports fixed. networkx/release.py networkx/release.py | 18 +++++++++++++----- +12d179db161dfaf04a7e95843cb081fd85b0738f aric none@none None Fri Aug 28 14:10:40 2009 +0000 2009-08-28 2009-08-28 14:10:40 stat 2 files changed, 72 insertions(+), 62 deletions(-) 2 72 62 Convert spectrum test to function style for nose and skip if numpy not avialable. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401440 networkx/linalg/tests/spectrum.txt;networkx/linalg/tests/test_spectrum.py networkx/linalg/tests/spectrum.txt | 62 -----------------------------;networkx/linalg/tests/test_spectrum.py | 72 ++++++++++++++++++++++++++++++++++ +bd9195fd617196b0b97957f386b316305de5b7c6 Aric Hagberg aric.hagberg@gmail.com gmail Fri Jul 19 21:26:03 2013 -0600 2013-07-20 2013-07-20 03:26:03 stat 1 file changed, 2 insertions(+), 1 deletion(-) 1 2 1 Add more packages to travis-ci config .travis.yml .travis.yml | 3 ++- +2c13b011439a7e99d89d99f3c218399d8c05a76f Kemal Maulana kemskems12@gmail.com gmail Sat May 17 01:39:26 2014 +0900 2014-05-16 2014-05-16 16:39:26 stat 1 file changed, 3 insertions(+) 1 3 Added references to Sphinx source file doc/source/reference/algorithms.link_prediction.rst doc/source/reference/algorithms.link_prediction.rst | 3 +++ +dc86deba83aa7e918ae46c4028c43c452301fa98 Jordi Torrents jordi.t21@gmail.com gmail Sun May 10 17:07:38 2015 +0200 2015-05-10 2015-05-10 15:07:38 stat 1 file changed, 111 insertions(+), 153 deletions(-) 1 111 153 Modernize biconnected tests, and remove subgraph attributes tests. .../components/tests/test_biconnected.py .../components/tests/test_biconnected.py | 264 +++++++++------------ +5377d9773e6f3da0b8ab05480c2c09a140e38f90 Moritz Emanuel Beber m.beber@jacobs-university.de jacobs-university Sat Sep 8 19:24:56 2012 +0200 2012-09-08 2012-09-08 17:24:56 stat 19 files changed, 2258 insertions(+) 19 2258 first file additions for community detection Added files from @bjedwards' GSoC repository over on bitbucket (https://bitbucket.org/bedwards/networkx-community) that have tests. Further files remain but testing needs to be added. networkx/algorithms/community/__init__.py;networkx/algorithms/community/community_quality.py;networkx/algorithms/community/community_utils.py;networkx/algorithms/community/divisive.py;networkx/algorithms/community/kernighan_lin.py;.../algorithms/community/laplacian_spectral.py;networkx/algorithms/community/partition.py;networkx/algorithms/community/quality.py;networkx/algorithms/community/random_community.py;.../algorithms/community/random_community_graph.py;.../community/tests/test_community_quality.py;.../community/tests/test_community_utils.py;.../algorithms/community/tests/test_divisive.py;.../community/tests/test_kernighan_lin.py;.../community/tests/test_laplacian_spectral.py;.../algorithms/community/tests/test_partition.py;.../algorithms/community/tests/test_quality.py;.../community/tests/test_random_community.py;.../community/tests/test_random_community_graph.py networkx/algorithms/community/__init__.py | 16 +;networkx/algorithms/community/community_quality.py | 305 ++++++++++++++;networkx/algorithms/community/community_utils.py | 137 +++++++;networkx/algorithms/community/divisive.py | 194 +++++++++;networkx/algorithms/community/kernighan_lin.py | 190 +++++++++;.../algorithms/community/laplacian_spectral.py | 112 ++++++;networkx/algorithms/community/partition.py | 211 ++++++++++;networkx/algorithms/community/quality.py | 90 +++++;networkx/algorithms/community/random_community.py | 189 +++++++++;.../algorithms/community/random_community_graph.py | 439 +++++++++++++++++++++;.../community/tests/test_community_quality.py | 55 +++;.../community/tests/test_community_utils.py | 22 ++;.../algorithms/community/tests/test_divisive.py | 57 +++;.../community/tests/test_kernighan_lin.py | 25 ++;.../community/tests/test_laplacian_spectral.py | 20 +;.../algorithms/community/tests/test_partition.py | 39 ++;.../algorithms/community/tests/test_quality.py | 9 +;.../community/tests/test_random_community.py | 87 ++++;.../community/tests/test_random_community_graph.py | 61 +++ +b502fecd90b06e2f6351d2e83de823b4f8073291 swart none@none None Fri Jun 16 21:06:15 2006 +0000 2006-06-16 2006-06-16 21:06:15 stat 2 files changed, 24 insertions(+), 22 deletions(-) 2 24 22 fixed nbunch documentation in subgraph and degree_iter since len(nbunch) is not required. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40287 networkx/base.py;networkx/xbase.py networkx/base.py | 33 +++++++++++++++++----------------;networkx/xbase.py | 13 +++++++------ +58f740d65883d6e7ee20936380f141650c5ec885 Minas Gjoka minas.gjoka@gmail.com gmail Sat Mar 12 16:59:39 2016 -0800 2016-03-13 2016-03-13 00:59:39 stat 3 files changed, 9 insertions(+), 9 deletions(-) 3 9 9 Change function name from joint_degree_model to joint_degree_graph doc/source/reference/generators.rst;networkx/generators/joint_degree_seq.py;networkx/generators/tests/test_joint_degree_seq.py doc/source/reference/generators.rst | 2 +-;networkx/generators/joint_degree_seq.py | 10 +++++-----;networkx/generators/tests/test_joint_degree_seq.py | 6 +++--- +6be86be3d06676627690135066a30db1973b930d Ben Edwards bedwards@cs.unm.edu cs.unm Thu Dec 1 14:20:54 2011 -0700 2011-12-01 2011-12-01 21:20:54 stat 1 file changed, 2 insertions(+), 3 deletions(-) 1 2 3 Altered flow_hierarchy to not save new graph, to save memory. networkx/algorithms/flow/hierarchy.py networkx/algorithms/flow/hierarchy.py | 5 ++--- +dc045e148ecaa376505f6cc710e732a5bd18fbec Aric Hagberg aric.hagberg@gmail.com gmail Sun Jul 28 15:50:48 2013 -0700 2013-07-28 2013-07-28 22:50:48 stat a509dde a3a440a Merge pull request #909 from hagberg/update-release-1.8 Update release 1.8 +4addc97325c44e51a976498593afd2e8106ce667 aric none@none None Thu Apr 15 04:30:57 2010 +0000 2010-04-15 2010-04-15 04:30:57 stat 27 files changed, 198 insertions(+), 225 deletions(-) 27 198 225 Remove with_labels keyword from *degree() methods. Addresses #337 --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401690 doc/source/reference/news.rst;doc/source/tutorial/tutorial.rst;examples/drawing/degree_histogram.py;examples/drawing/ego_graph.py;examples/graph/degree_sequence.py;examples/graph/football.py;networkx/algorithms/core.py;networkx/algorithms/isomorphism/isomorph.py;networkx/algorithms/isomorphism/isomorphvf2.py;networkx/algorithms/link_analysis/pagerank.py;networkx/classes/digraph.py;networkx/classes/function.py;networkx/classes/graph.py;networkx/classes/tests/digraph_DiGraph.txt;networkx/classes/tests/graph_Graph.txt;networkx/classes/tests/test_digraph.py;networkx/classes/tests/test_graph.py;networkx/classes/tests/test_multidigraph.py;networkx/generators/degree_seq.py;networkx/generators/directed.py;networkx/generators/stochastic.py;networkx/generators/tests/bipartite.txt;networkx/generators/tests/classic.txt;networkx/generators/tests/degree_seq.txt;networkx/generators/tests/small.txt;networkx/generators/threshold.py;networkx/tests/convert.txt doc/source/reference/news.rst | 2 +;doc/source/tutorial/tutorial.rst | 26 +++++--------;examples/drawing/degree_histogram.py | 2 +-;examples/drawing/ego_graph.py | 2 +-;examples/graph/degree_sequence.py | 2 +-;examples/graph/football.py | 2 +-;networkx/algorithms/core.py | 2 +-;networkx/algorithms/isomorphism/isomorph.py | 12 +++---;networkx/algorithms/isomorphism/isomorphvf2.py | 4 +-;networkx/algorithms/link_analysis/pagerank.py | 4 +-;networkx/classes/digraph.py | 49 +++++++++--------------;networkx/classes/function.py | 6 +--;networkx/classes/graph.py | 24 +++++-------;networkx/classes/tests/digraph_DiGraph.txt | 46 ++++++++++------------;networkx/classes/tests/graph_Graph.txt | 32 +++++++--------;networkx/classes/tests/test_digraph.py | 18 ++++-----;networkx/classes/tests/test_graph.py | 18 ++++-----;networkx/classes/tests/test_multidigraph.py | 18 ++++-----;networkx/generators/degree_seq.py | 14 +++----;networkx/generators/directed.py | 8 ++--;networkx/generators/stochastic.py | 4 +-;networkx/generators/tests/bipartite.txt | 24 ++++++------;networkx/generators/tests/classic.txt | 10 ++---;networkx/generators/tests/degree_seq.txt | 12 +++---;networkx/generators/tests/small.txt | 54 +++++++++++++-------------;networkx/generators/threshold.py | 4 +-;networkx/tests/convert.txt | 24 ++++++------ +ea71e3ee025383ad3852124c1bc634cb6f02a360 aric none@none None Mon Dec 12 22:22:56 2005 +0000 2005-12-12 2005-12-12 22:22:56 stat 1 file changed, 4 insertions(+), 8 deletions(-) 1 4 8 cleanup of test code --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40110 networkx/tests/test.py networkx/tests/test.py | 12 ++++-------- +3deb69c6c63fb7499ba439153b08d7bef6eef20b cellison none@none None Mon May 4 02:16:44 2009 +0000 2009-05-04 2009-05-04 02:16:44 stat 1 file changed, 5 deletions(-) 1 5 removing debug statements introduced in last changeset --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401196 networkx/algorithms/isomorphism/isomorphvf2.py networkx/algorithms/isomorphism/isomorphvf2.py | 5 ----- +9b9284ccefc7ad0bc19e55c0de0fdaa9029d6d69 Jamal jamalsenouci@gmail.com gmail Tue Nov 25 06:01:01 2014 +0000 2014-11-25 2014-11-25 06:01:01 stat 1 file changed, 134 insertions(+), 3 deletions(-) 1 134 3 added to_pandas_dataframe and from_pandas_dataframe networkx/convert_matrix.py networkx/convert_matrix.py | 137 ++++++++++++++++++++++++++++++++++++++++++++- +2b88f65b2587a789d8149e8c692ed957a874c6ec ysitu ysitu@users.noreply.github.com users.noreply.github Mon Aug 4 16:30:20 2014 -0400 2014-08-04 2014-08-04 20:30:20 stat 1 file changed, 17 insertions(+), 8 deletions(-) 1 17 8 Prioritize Travis jobs to reduce turn-around time .travis.yml .travis.yml | 25 +++++++++++++++++-------- +08f6f0062195c466d981a5d3a2342666397c5af1 chebee7i chebee7i@gmail.com gmail Sat Nov 14 08:13:20 2015 -0600 2015-11-14 2015-11-14 14:13:20 stat 4ff2367 21b7915 Merge pull request #1840 from sieben/simplify_chain_comparisons Simplify chain comparisons +2d9a2a5456ad2affaa08db96635a6e6d256d9b10 Dan Schult dschult@colgate.edu colgate Sun Jan 4 22:42:54 2015 -0500 2015-01-05 2015-01-05 03:42:54 stat 1 file changed, 9 insertions(+), 18 deletions(-) 1 9 18 Clean up shp using new dgal/ogr iterator interface for loops. networkx/readwrite/nx_shp.py networkx/readwrite/nx_shp.py | 27 +++++++++------------------ +7e92a03fc43990bdab0d4fe3b69f3bb7d41d7020 Jordi Torrents jordi.t21@gmail.com gmail Mon Mar 16 11:42:16 2015 +0100 2015-03-16 2015-03-16 10:42:16 stat 1 file changed, 5 insertions(+) 1 5 Update `api_2.0.rst`. doc/source/reference/api_2.0.rst doc/source/reference/api_2.0.rst | 5 +++++ +7f8f7da119df684f9a71403dc86e25a35962a851 aric none@none None Sun Jul 22 12:52:43 2007 +0000 2007-07-22 2007-07-22 12:52:43 stat 2 files changed, 1 insertion(+), 46 deletions(-) 2 1 46 simplify Readme, Install typos --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40650 doc/Install.txt;doc/Readme.txt doc/Install.txt | 2 +-;doc/Readme.txt | 45 --------------------------------------------- +4b57c81b2467819a95fa6f6494cdcc255b06f67b Aric Hagberg aric.hagberg@gmail.com gmail Sun Sep 8 14:59:43 2013 -0600 2013-09-08 2013-09-08 20:59:43 stat 2 files changed, 17 insertions(+) 2 17 Add docs doc/source/reference/algorithms.rst;doc/source/reference/algorithms.tree.rst doc/source/reference/algorithms.rst | 1 +;doc/source/reference/algorithms.tree.rst | 16 ++++++++++++++++ +4c46633c23caf7b483549c111304bf461bd67eb6 aric none@none None Fri Apr 9 15:18:07 2010 +0000 2010-04-09 2010-04-09 15:18:07 stat 2 files changed, 137 insertions(+), 1 deletion(-) 2 137 1 Directed configuration model --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401678 doc/source/reference/generators.rst;networkx/generators/degree_seq.py doc/source/reference/generators.rst | 1 +;networkx/generators/degree_seq.py | 137 +++++++++++++++++++++++++++++++++++- +8d6200dc8f5d84ced753ab0bd6105ad6a7eaf010 Aric Hagberg aric.hagberg@gmail.com gmail Thu Mar 10 16:31:41 2011 -0700 2011-03-10 2011-03-10 23:31:41 stat 1 file changed, 17 insertions(+), 4 deletions(-) 1 17 4 In projections, when returning multigraphs use neighbor as key. Addresses #514 networkx/algorithms/bipartite/projection.py networkx/algorithms/bipartite/projection.py | 21 +++++++++++++++++---- +4760d0acf4a4c82b468974360cac942fd7a9c022 Kemal Maulana kemskems12@gmail.com gmail Wed Apr 23 17:42:10 2014 +0900 2014-04-23 2014-04-23 08:42:10 stat 1 file changed, 54 insertions(+), 87 deletions(-) 1 54 87 Refined tests .../link_prediction/tests/test_predict.py .../link_prediction/tests/test_predict.py | 141 ++++++++------------- +692000e28f41c0f8ef54d7fa02bbae3e4a40a367 Chris Ellison cellison@cse.ucdavis.edu cse.ucdavis Tue Oct 5 12:28:15 2010 -0700 2010-10-05 2010-10-05 19:28:15 stat 3 files changed, 129 insertions(+), 157 deletions(-) 3 129 157 Simplified hg revision. Shortcut for non-dev release. Addresses #413 networkx/release.py;networkx/sys.py;setup.py networkx/release.py | 242 ++++++++++++++++++++++++++--------------------------;networkx/sys.py | 38 +--------;setup.py | 6 +- +5c8db4466e3a8ff32cc2677dc9afe9b9ff846b4d Ramil Nugmanov stsouko@live.ru live Sun Oct 18 13:36:45 2015 +0300 2015-10-18 2015-10-18 10:36:45 stat 1 file changed, 2 insertions(+), 3 deletions(-) 1 2 3 categorical match fix networkx/algorithms/isomorphism/matchhelpers.py networkx/algorithms/isomorphism/matchhelpers.py | 5 ++--- +09fd171d9fbb2d9e81e09ae87e436cc6aaabdf00 Aric Hagberg aric.hagberg@gmail.com gmail Sun Apr 15 15:44:38 2012 -0600 2012-04-15 2012-04-15 21:44:38 stat 3 files changed, 75 insertions(+), 15 deletions(-) 3 75 15 Add maximal_matching. Addresses #714 doc/source/reference/algorithms.matching.rst;networkx/algorithms/matching.py;networkx/algorithms/tests/test_matching.py doc/source/reference/algorithms.matching.rst | 2 +-;networkx/algorithms/matching.py | 49 ++++++++++++++++++++--------;networkx/algorithms/tests/test_matching.py | 39 +++++++++++++++++++++- +0c3f1702b11b86bbe7d9273f6a98c1455cc731a6 Aric Hagberg aric.hagberg@gmail.com gmail Sat Dec 10 11:34:29 2011 -0700 2011-12-10 2011-12-10 18:34:29 stat 2 files changed, 20 insertions(+), 4 deletions(-) 2 20 4 Update bipartite tests. networkx/algorithms/bipartite/tests/test_basic.py;networkx/algorithms/bipartite/tests/test_centrality.py networkx/algorithms/bipartite/tests/test_basic.py | 17 +++++++++++++----;networkx/algorithms/bipartite/tests/test_centrality.py | 7 +++++++ +bfe366ac674e8e074a5fe790287fbc724aca0e5b aric none@none None Sun Aug 6 13:50:55 2006 +0000 2006-08-06 2006-08-06 13:50:55 stat 1 file changed, 14 insertions(+), 7 deletions(-) 1 14 7 Use numpy (preferred) or Numeric. Fixes #60. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40357 doc/examples/eigenvalues.py doc/examples/eigenvalues.py | 21 ++++++++++++++------- +2081f2e108bae68eebef89f7b996efd431760c2e Jeffrey Finkelstein jeffrey.finkelstein@gmail.com gmail Wed Oct 28 10:46:26 2015 -0400 2015-10-28 2015-10-28 14:46:26 stat 1 file changed, 13 insertions(+) 1 13 Adds unit test for new use of string.format(). networkx/classes/tests/test_graph.py networkx/classes/tests/test_graph.py | 13 +++++++++++++ +1d127b7f5632002320a79604c344a761cfa0703b alexnikleo anikitin@rubbles.ru rubbles Tue Jun 23 12:24:59 2015 +0300 2015-06-23 2015-06-23 09:24:59 stat 11 files changed, 64 insertions(+), 11 deletions(-) 11 64 11 NetworkXInvalidNode exception added doc/source/reference/api_2.0.rst;doc/source/reference/exceptions.rst;networkx/algorithms/shortest_paths/astar.py;networkx/algorithms/shortest_paths/generic.py;networkx/algorithms/shortest_paths/tests/test_astar.py;.../algorithms/shortest_paths/tests/test_weighted.py;networkx/algorithms/shortest_paths/unweighted.py;networkx/algorithms/shortest_paths/weighted.py;networkx/algorithms/simple_paths.py;networkx/algorithms/tests/test_simple_paths.py;networkx/exception.py doc/source/reference/api_2.0.rst | 18 ++++++++++++++++++;doc/source/reference/exceptions.rst | 2 ++;networkx/algorithms/shortest_paths/astar.py | 6 ++++++;networkx/algorithms/shortest_paths/generic.py | 12 ++++++++++--;networkx/algorithms/shortest_paths/tests/test_astar.py | 2 +-;.../algorithms/shortest_paths/tests/test_weighted.py | 4 ++--;networkx/algorithms/shortest_paths/unweighted.py | 13 +++++++++++++;networkx/algorithms/shortest_paths/weighted.py | 7 +++++--;networkx/algorithms/simple_paths.py | 4 ++--;networkx/algorithms/tests/test_simple_paths.py | 4 ++--;networkx/exception.py | 3 +++ +a9501a3ba9aaf2165d7508fd8213f32960f7adf1 Chris Ellison cellison@cse.ucdavis.edu cse.ucdavis Tue Nov 23 19:36:37 2010 -0800 2010-11-24 2010-11-24 03:36:37 stat 2 files changed, 44 insertions(+), 36 deletions(-) 2 44 36 Allow setup to proceed even if version.py does not exist. Addresses #472 networkx/release.py;networkx/sys.py networkx/release.py | 77 ++++++++++++++++++++++++++++-------------------------;networkx/sys.py | 3 +++ +3cbdc901c7089d0243f318cd200f40637bf87ee5 Aric Hagberg aric.hagberg@gmail.com gmail Wed Sep 21 10:17:16 2011 -0600 2011-09-21 2011-09-21 16:17:16 stat 1 file changed, 5 insertions(+), 2 deletions(-) 1 5 2 Add svg yfiles patch. Fixes #635 networkx/readwrite/graphml.py networkx/readwrite/graphml.py | 7 +++++-- +9b602cb439a59b7d9d340f756805fe04c0ea3b7b Aric Hagberg aric.hagberg@gmail.com gmail Sun Apr 8 14:30:13 2012 -0600 2012-04-08 2012-04-08 20:30:13 stat 1 file changed, 5 insertions(+), 5 deletions(-) 1 5 5 Force floats in communicability_alg Addresses #698 networkx/algorithms/centrality/communicability_alg.py networkx/algorithms/centrality/communicability_alg.py | 10 +++++----- +bff4606025d528f807130d3942e96a371b0b7a5c Aric Hagberg aric.hagberg@gmail.com gmail Sun Jan 15 10:46:46 2012 -0700 2012-01-15 2012-01-15 17:46:46 stat 969049a 3fbf1b3 Merge commit +8bdba8cb79166fd3f63a32f0efa0839147b97dc9 aric none@none None Sun Jan 7 01:56:28 2007 +0000 2007-01-07 2007-01-07 01:56:28 stat 2 files changed, 20 insertions(+), 9 deletions(-) 2 20 9 create_empty_copy should work like empty_graph. That is, H=create_empty_copy(G) now produces a copy of the graph G with all of the edges removed - an empty graph of len(G) nodes. Fixes #82. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40508 networkx/operators.py;networkx/tests/operators.txt networkx/operators.py | 18 +++++++++---------;networkx/tests/operators.txt | 11 +++++++++++ +c7aaf183b677fcc94b12b99c5f44695f6618c2dd aric none@none None Thu Apr 29 14:04:04 2010 +0000 2010-04-29 2010-04-29 14:04:04 stat 1 file changed, 2 insertions(+), 2 deletions(-) 1 2 2 Change name of pagerank and hits modules in docs --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401737 doc/source/reference/algorithms.link_analysis.rst doc/source/reference/algorithms.link_analysis.rst | 4 ++-- +25086b5bb00f0c879749de60bef610f37c6625a3 Aric Hagberg aric.hagberg@gmail.com gmail Sat Nov 9 10:56:03 2013 -0700 2013-11-09 2013-11-09 17:56:03 stat 1 file changed, 7 deletions(-) 1 7 Clean up the mess I left in #1006 Remove a print statement and some commented out code. networkx/utils/misc.py networkx/utils/misc.py | 7 ------- +bbebe033710fa5be8b57a438436b916c700ad73d Aric Hagberg aric.hagberg@gmail.com gmail Fri Jul 19 19:28:54 2013 -0600 2013-07-20 2013-07-20 01:28:54 stat 1 file changed, 1 insertion(+), 1 deletion(-) 1 1 1 Update travis.ci config .travis.yml .travis.yml | 2 +- +52ab8b902f9be71d001cfbe63bec82701ae5f0c4 Jordi Torrents jordi.t21@gmail.com gmail Tue Aug 28 21:20:04 2012 +0200 2012-08-28 2012-08-28 19:20:04 stat 2 files changed, 29 insertions(+), 17 deletions(-) 2 29 17 fix load_betweeness bug when computing it for one node in a non strongly connected digraph networkx/algorithms/centrality/load.py;.../centrality/tests/test_load_centrality.py networkx/algorithms/centrality/load.py | 21 +++++++++++-------;.../centrality/tests/test_load_centrality.py | 25 ++++++++++++++-------- +3a9695c6dfeee6ab5c63fd8b1ca61873b5ed9a0c Aric Hagberg aric.hagberg@gmail.com gmail Tue Aug 13 08:20:55 2013 -0700 2013-08-13 2013-08-13 15:20:55 stat b564954 c74fef6 Merge pull request #929 from brycethomas/issue928 Fixes #928 +6943d0c7965bc597f6f78becfbfd436496868e1e Aric Hagberg aric.hagberg@gmail.com gmail Tue Jan 29 07:55:50 2013 -0700 2013-01-29 2013-01-29 14:55:50 stat 1 file changed, 16 insertions(+), 16 deletions(-) 1 16 16 Whitespace cleanup and formatting networkx/linalg/laplacianmatrix.py networkx/linalg/laplacianmatrix.py | 32 ++++++++++++++++---------------- +d2955da58905d349971171e613b19d7c0766a3f7 chebee7i chebee7i@gmail.com gmail Wed Apr 30 12:00:36 2014 -0500 2014-04-30 2014-04-30 17:00:36 stat 8bd36c8 40a804b Merge pull request #1132 from chebee7i/coveralls Remove deprecated --use-mirrors in pip command. +f9175d38f1e1719899aa2972554672584da80494 Scinawa alessandro.luongo@studenti.unimi.it studenti.unimi Sat Feb 28 19:05:23 2015 +0100 2015-02-28 2015-02-28 18:05:23 stat 886a7cb ada85ee Merge pull request #2 from chebee7i/harmonic2 Add harmonic_centrality to release notes. +d2f5b5179b2ec6f7702360fdeca30cff4a369200 Haochen Wu wuhaochen42@gmail.com gmail Sat Oct 17 17:44:48 2015 -0700 2015-10-18 2015-10-18 00:44:48 stat 1 file changed, 1 insertion(+), 1 deletion(-) 1 1 1 fix type issue networkx/linalg/algebraicconnectivity.py networkx/linalg/algebraicconnectivity.py | 2 +- +feeab543fe9aafe0f333b43b47f3154c6219abf7 Brandon Liu brandon.k.liu@gmail.com gmail Sat Nov 2 14:49:20 2013 -0400 2013-11-02 2013-11-02 18:49:20 stat 1 file changed, 62 insertions(+), 61 deletions(-) 1 62 61 Having dangling vector default to the personalization vector networkx/algorithms/link_analysis/pagerank_alg.py networkx/algorithms/link_analysis/pagerank_alg.py | 123 +++++++++++----------- +3456460c44f66611d85d24a28bc0d596fd5e09d7 Mridul Seth seth.mridul@gmail.com gmail Thu Aug 13 23:52:41 2015 +0530 2015-08-13 2015-08-13 18:22:41 stat 17 files changed, 62 insertions(+), 57 deletions(-) 17 62 57 Update single_source_shortest_path_length and all_pairs_shortest_path_length to return iterators networkx/algorithms/bipartite/centrality.py;networkx/algorithms/centrality/closeness.py;networkx/algorithms/centrality/harmonic.py;networkx/algorithms/connectivity/stoerwagner.py;networkx/algorithms/dag.py;networkx/algorithms/distance_measures.py;networkx/algorithms/distance_regular.py;networkx/algorithms/flow/maxflow.py;networkx/algorithms/shortest_paths/generic.py;.../shortest_paths/tests/test_generic.py;.../shortest_paths/tests/test_unweighted.py;networkx/algorithms/shortest_paths/unweighted.py;.../algorithms/tests/test_distance_measures.py;networkx/algorithms/vitality.py;networkx/generators/ego.py;networkx/generators/tests/test_threshold.py;networkx/utils/rcm.py networkx/algorithms/bipartite/centrality.py | 8 +++---;networkx/algorithms/centrality/closeness.py | 2 +-;networkx/algorithms/centrality/harmonic.py | 10 ++++++--;networkx/algorithms/connectivity/stoerwagner.py | 2 +-;networkx/algorithms/dag.py | 4 +--;networkx/algorithms/distance_measures.py | 4 +--;networkx/algorithms/distance_regular.py | 2 +-;networkx/algorithms/flow/maxflow.py | 2 +-;networkx/algorithms/shortest_paths/generic.py | 21 +++++++--------;.../shortest_paths/tests/test_generic.py | 14 +++++-----;.../shortest_paths/tests/test_unweighted.py | 6 ++---;networkx/algorithms/shortest_paths/unweighted.py | 30 ++++++++++------------;.../algorithms/tests/test_distance_measures.py | 2 +-;networkx/algorithms/vitality.py | 2 +-;networkx/generators/ego.py | 6 ++---;networkx/generators/tests/test_threshold.py | 2 +-;networkx/utils/rcm.py | 2 +- +00cbaa3f5605a2391f29996640a297a7a73db028 Jordi Torrents jordi.t21@gmail.com gmail Fri May 8 14:28:13 2015 +0200 2015-05-08 2015-05-08 12:28:13 stat 1bc0f19 ec4081a Merge pull request #1515 from jfinkels/simplify-karate Simplifies the code for the karate club graph. +3e6b9280a3c436df86f95feb1204852aca76a689 aric none@none None Sat Aug 7 15:40:21 2010 +0000 2010-08-07 2010-08-07 15:40:21 stat 1 file changed, 3 insertions(+), 3 deletions(-) 1 3 3 Instructions for OSX --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401866 doc/source/install.rst doc/source/install.rst | 6 +++--- +63304e5171cac05133001fc24fa7cf5f0ffa2f55 ysitu ysitu@users.noreply.github.com users.noreply.github Sun May 4 13:48:14 2014 -0400 2014-05-04 2014-05-04 17:48:14 stat 1 file changed, 3 insertions(+) 1 3 Install scikits.sparse in updated .travis.yml .travis.yml .travis.yml | 3 +++ +7dbb901667cbff86ff3e93d02461af771acb1faa chebee7i chebee7i@gmail.com gmail Fri Apr 24 18:18:56 2015 -0500 2015-04-24 2015-04-24 23:18:56 stat 1 file changed, 6 insertions(+), 6 deletions(-) 1 6 6 Use 'theta' instead of 't'. networkx/drawing/layout.py networkx/drawing/layout.py | 12 ++++++------ +ee5421def5beb5a8ad2afdf9ffad38022a179905 Jeffrey Finkelstein jeffrey.finkelstein@gmail.com gmail Thu Jul 30 21:26:19 2015 -0400 2015-07-31 2015-07-31 01:26:19 stat 2 files changed, 287 insertions(+), 117 deletions(-) 2 287 117 Allows weight functions in shortest path functions This commit allows the user to provide an arbitrary function that computes the weight of an edge instead of relying on an edge attribute. .../shortest_paths/tests/test_weighted.py;networkx/algorithms/shortest_paths/weighted.py .../shortest_paths/tests/test_weighted.py | 34 +-;networkx/algorithms/shortest_paths/weighted.py | 370 ++++++++++++++------- +24292a0b1e1abed8d2f3f967acd544f9c78b4d1b Lucas Jones ljnj@st-andrews.ac.uk st-andrews.ac Mon Mar 30 18:48:04 2015 +0100 2015-03-30 2015-03-30 17:48:04 stat 1 file changed, 2 insertions(+), 2 deletions(-) 1 2 2 Fix style issues in circulant graph generator. networkx/generators/classic.py networkx/generators/classic.py | 4 ++-- +4165886c1bcf9341355d28fb79a0ccd29707639a ysitu ysitu@users.noreply.github.com users.noreply.github Tue Apr 8 19:28:44 2014 -0400 2014-04-08 2014-04-08 23:28:44 stat 4 files changed, 159 insertions(+), 141 deletions(-) 4 159 141 Move auxiliary stuff used by maxflow algorithms to separate file networkx/algorithms/flow/__init__.py;networkx/algorithms/flow/preflow_push.py;.../algorithms/flow/shortest_augmenting_path.py;networkx/algorithms/flow/utils.py networkx/algorithms/flow/__init__.py | 2 +;networkx/algorithms/flow/preflow_push.py | 141 +-------------------;.../algorithms/flow/shortest_augmenting_path.py | 12 +-;networkx/algorithms/flow/utils.py | 145 +++++++++++++++++++++ +577a45acc7a0690c100b2f8005ba812aeaa381fa swatmad swatmad@gmail.com gmail Thu Dec 5 22:07:15 2013 +0400 2013-12-05 2013-12-05 18:07:15 stat 2 files changed, 33 insertions(+), 21 deletions(-) 2 33 21 fast euler cycle algorithm implemented networkx/algorithms/euler.py;networkx/algorithms/tests/test_euler.py networkx/algorithms/euler.py | 42 +++++++++++++++++++++------------;networkx/algorithms/tests/test_euler.py | 12 +++++----- +f8663bcc9372e95e07eb914d224680663ce40afc ysitu ysitu@users.noreply.github.com users.noreply.github Sat Mar 22 01:00:38 2014 -0400 2014-03-22 2014-03-22 05:00:38 stat 1 file changed, 3 insertions(+), 3 deletions(-) 1 3 3 Fix typo and avoid line breaking after hyphen in preflow-push maxflow algorithm networkx/algorithms/flow/preflow_push.py networkx/algorithms/flow/preflow_push.py | 6 +++--- +71f58d18070ae8c226e3339344ce2a595f2f2eaf Aric Hagberg aric.hagberg@gmail.com gmail Sun Feb 6 13:04:50 2011 -0700 2011-02-06 2011-02-06 20:04:50 stat 2 files changed, 132 insertions(+), 57 deletions(-) 2 132 57 Add weighted option to clustering. Fixes #493 networkx/algorithms/cluster.py;networkx/algorithms/tests/test_cluster.py networkx/algorithms/cluster.py | 125 +++++++++++++++++++-----------;networkx/algorithms/tests/test_cluster.py | 64 ++++++++++++--- +0e6fec9c73727669ae6e2f7683a058f7adca3817 Kemal Maulana kemskems12@gmail.com gmail Tue Apr 29 23:36:40 2014 +0900 2014-04-29 2014-04-29 14:36:40 stat 1 file changed, 6 insertions(+) 1 6 Added __all__ networkx/algorithms/link_prediction.py networkx/algorithms/link_prediction.py | 6 ++++++ +f2ee68fca66ade5a55e0a904477d16aded73b81e Dan Schult dschult@colgate.edu colgate Mon Nov 21 15:34:46 2011 -0500 2011-11-21 2011-11-21 20:34:46 stat 2 files changed, 3 insertions(+), 3 deletions(-) 2 3 3 Correct name for "see also" docstrings with method nodes_with_selfloops() Addresses #653 networkx/classes/graph.py;networkx/classes/multigraph.py networkx/classes/graph.py | 4 ++--;networkx/classes/multigraph.py | 2 +- +1c629f86d955425a429facfd6f87e9955a9f3b00 Shaun Jackman sjackman@gmail.com gmail Sat Jun 27 17:32:37 2015 -0700 2015-06-28 2015-06-28 00:32:37 stat 2 files changed, 31 insertions(+), 14 deletions(-) 2 31 14 dag_longest_path: Use edge weights If G has edges with 'weight' attribute the edge data are used as weight values. networkx/algorithms/dag.py;networkx/algorithms/tests/test_dag.py networkx/algorithms/dag.py | 37 ++++++++++++++++++++++-------------;networkx/algorithms/tests/test_dag.py | 8 ++++++++ +50b5b659a7329f89afd58e929eada10c6ec211ca aric none@none None Thu Nov 20 02:51:24 2008 +0000 2008-11-20 2008-11-20 02:51:24 stat 2 files changed, 195 insertions(+), 102 deletions(-) 2 195 102 document convert module --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401036 doc/source/reference/convert.rst;networkx/convert.py doc/source/reference/convert.rst | 21 +++;networkx/convert.py | 276 ++++++++++++++++++++++++--------------- +825d185c3eef4131c3f5e1b33922b0b4c62c45bf chebee7i chebee7i@gmail.com gmail Wed May 6 17:35:11 2015 -0500 2015-05-06 2015-05-06 22:35:11 stat 248d3f2 508ad5a Merge pull request #1510 from SanketDG/docfix2 Docstring fix for strongly_connected_components_recursive() +e624e888e4b8d4ccbcdc0be6eca5e3e3be7de6f5 Aric Hagberg aric.hagberg+github@gmail.com gmail Sat Apr 16 07:42:04 2016 -0600 2016-04-16 2016-04-16 13:42:04 stat 5232880 af8a2d8 Merge pull request #2039 from jfinkels/approx-vertex-cover Support digraphs in approximate min vertex cover +619e89f26a0fe3f0aae73e1d9405fca86d073f54 aric none@none None Sat Jul 29 12:51:22 2006 +0000 2006-07-29 2006-07-29 12:51:22 stat 1 file changed, 17 insertions(+), 17 deletions(-) 1 17 17 adjust layout --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40341 doc/Contributing.txt doc/Contributing.txt | 34 +++++++++++++++++----------------- +5d653919bc81543e2534bdaed751aa3e1ae1e14d Mridul Seth seth.mridul@gmail.com gmail Sun Jun 7 14:13:08 2015 +0530 2015-06-07 2015-06-07 08:43:08 stat 1 file changed, 6 insertions(+) 1 6 Add bfs test for directed graph in reverse direction networkx/algorithms/traversal/tests/test_bfs.py networkx/algorithms/traversal/tests/test_bfs.py | 6 ++++++ +c932df65228ba518484a28415959a45f2dc90ea7 Ryan Nelson rnelsonchem@gmail.com gmail Sat Jan 24 18:50:07 2015 -0500 2015-01-24 2015-01-24 23:50:07 stat 1 file changed, 13 insertions(+), 13 deletions(-) 1 13 13 Fixed the kwarg descriptions networkx/convert_matrix.py networkx/convert_matrix.py | 26 +++++++++++++------------- +d3b2f8c46a89b3ba2b77f19ef8ad17f0fd34dd67 aric none@none None Sun Aug 17 12:41:37 2008 +0000 2008-08-17 2008-08-17 12:41:37 stat 1 file changed, 12 insertions(+), 4 deletions(-) 1 12 4 Add secondary sort option for topological sort Fixes #174 --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40831 networkx/dag.py networkx/dag.py | 16 ++++++++++++---- +5dc8f93cddc9a58cfb88a5ca34e6968eba5d27c6 Aric Hagberg aric.hagberg@gmail.com gmail Fri Dec 28 09:08:53 2012 -0700 2012-12-28 2012-12-28 16:08:53 stat 2 files changed, 16 insertions(+), 2 deletions(-) 2 16 2 Skip tests if scipy not installed. networkx/algorithms/link_analysis/tests/test_hits.py;networkx/algorithms/link_analysis/tests/test_pagerank.py networkx/algorithms/link_analysis/tests/test_hits.py | 9 ++++++++-;networkx/algorithms/link_analysis/tests/test_pagerank.py | 9 ++++++++- +f0e214e904b00b0c78d7eaef3c3c900a56e8b7b1 Aric Hagberg aric.hagberg+github@gmail.com gmail Sun May 10 12:06:49 2015 -0600 2015-05-10 2015-05-10 18:06:49 stat 4ee63ee 3943658 Merge pull request #1501 from jtorrents/refactor-connected-components Refactor connected components +3897ce48d4d4115d90ebeb0f3ac2731b2b883225 aric none@none None Thu Dec 1 17:24:31 2005 +0000 2005-12-01 2005-12-01 17:24:31 stat 1 file changed, 15 deletions(-) 1 15 MANIFEST will be built from svn repository data no need for MANIFEST.in --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%4090 MANIFEST.in MANIFEST.in | 15 --------------- +d9b6b35c49a0d8e639a25dd342f5a0d7209e45b9 Aric Hagberg aric.hagberg@gmail.com gmail Sun Nov 13 18:18:25 2011 -0700 2011-11-14 2011-11-14 01:18:25 stat 3 files changed, 93 insertions(+) 3 93 Ad k-clique. Addreses #652 networkx/algorithms/__init__.py;networkx/algorithms/community/kclique.py;.../algorithms/community/tests/test_kclique.py networkx/algorithms/__init__.py | 1 +;networkx/algorithms/community/kclique.py | 78 ++++++++++++++++++++++;.../algorithms/community/tests/test_kclique.py | 14 ++++ +c00cf03675a605dd687ef28f7ae312b90f83aedd Aric Hagberg aric.hagberg+github@gmail.com gmail Fri Jan 9 11:05:27 2015 -0700 2015-01-09 2015-01-09 18:05:27 stat 85c2bae a85bcee Merge pull request #1262 from jdrudolph/json-graph-attributes-as-dict node-link repr. contains graph dict 'as is' +91d254c67767411e847d610f0fe89485df602797 Aric Hagberg aric.hagberg@gmail.com gmail Sun Dec 15 10:21:32 2013 -0700 2013-12-15 2013-12-15 17:21:32 stat 1 file changed, 145 insertions(+), 6 deletions(-) 1 145 6 Add docs networkx/readwrite/sparse6.py networkx/readwrite/sparse6.py | 151 ++++++++++++++++++++++++++++++++++++++++-- +dd673132420b59083200f31fcae7ca9231c7535f Aric Hagberg aric.hagberg+github@gmail.com gmail Sun Dec 27 13:39:17 2015 -0700 2015-12-27 2015-12-27 20:39:17 stat 2829e5a 5bf43d2 Merge pull request #1845 from jfinkels/community-quality Adds functions for measuring "quality" of a partition +09bd53b65aa6d3a6c0c422f46cf1c5c0fffa4245 aric none@none None Mon Jul 25 22:31:09 2005 +0000 2005-07-25 2005-07-25 22:31:09 stat 1 file changed, 1 insertion(+), 3 deletions(-) 1 1 3 Documentation to match code. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%4035 networkx/generators/random_graphs.py networkx/generators/random_graphs.py | 4 +--- +c126504cf60512a1ef240ef1d50ea7cc4d2725a5 aric none@none None Fri Jan 25 01:11:34 2008 +0000 2008-01-25 2008-01-25 01:11:34 stat 1 file changed, 3 insertions(+), 1 deletion(-) 1 3 1 Allow linewidths keyword for drawing nodes (see pylab.scatter for details). Fixes #145. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40721 networkx/drawing/nx_pylab.py networkx/drawing/nx_pylab.py | 4 +++- +dcff03131eefc1d3475e93035764c9757bb4c511 chebee7i chebee7i@gmail.com gmail Sat Feb 28 11:09:36 2015 -0600 2015-02-28 2015-02-28 17:09:36 stat 1 file changed, 6 insertions(+), 14 deletions(-) 1 6 14 Remove node option for harmonic_centrality(). networkx/algorithms/centrality/harmonic.py networkx/algorithms/centrality/harmonic.py | 20 ++++++-------------- +e0659b52a7b63777b03075e9a82e577bf4185530 ysitu ysitu@users.noreply.github.com users.noreply.github Mon Nov 3 18:27:46 2014 -0800 2014-11-04 2014-11-04 02:27:46 stat 1 file changed, 7 insertions(+), 1 deletion(-) 1 7 1 Add network simplex method rewrite to 2.0 release notes doc/source/reference/api_2.0.rst doc/source/reference/api_2.0.rst | 8 +++++++- +9857703425a011e92d4f8c4b2b0f59b375126f4b Aric Hagberg aric.hagberg@gmail.com gmail Tue Nov 16 20:06:18 2010 -0700 2010-11-17 2010-11-17 03:06:18 stat 2 files changed, 60 insertions(+), 2 deletions(-) 2 60 2 Add MultiDiGraph in_edges() and out_edges() methods. Addresses #469 networkx/classes/multidigraph.py;networkx/classes/tests/test_multidigraph.py networkx/classes/multidigraph.py | 58 +++++++++++++++++++++++++++++;networkx/classes/tests/test_multidigraph.py | 4 +- +363707aab7e76e52f521c07517d53c1ee7466900 aric none@none None Wed Jun 24 18:06:59 2009 +0000 2009-06-24 2009-06-24 18:06:59 stat 1 file changed, 2 insertions(+), 2 deletions(-) 1 2 2 Missing networkx import and typo in class comparison --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401222 networkx/algorithms/hits.py networkx/algorithms/hits.py | 4 ++-- +334269cea08c73de1e21e8df919043fdda4394c4 aric none@none None Sat Nov 15 15:12:44 2008 +0000 2008-11-15 2008-11-15 15:12:44 stat 8 files changed, 79 insertions(+), 116 deletions(-) 8 79 116 Rework test code. networkx.test() runs all of the .txt doctests but not the test_*.py tests or the docstring tests in the modules. use nosetests with the networkx-nose-plugin to test the entire package with python setup_egg.py nosetests --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40986 networkx/__init__.py;networkx/tests/README;networkx/tests/__init__.py;networkx/tests/benchmark.py;networkx/tests/run.py;networkx/tests/test.py;setup.py;setup_egg.py networkx/__init__.py | 2 +-;networkx/tests/README | 35 +++++++-----------;networkx/tests/__init__.py | 0;networkx/tests/benchmark.py | 30 +++++++--------;networkx/tests/run.py | 27 --------------;networkx/tests/test.py | 89 +++++++++++++++++++++------------------------;setup.py | 9 +++--;setup_egg.py | 3 +- +bf03738c5af55533047a329d832af66742f4aa5e aric none@none None Sat Jun 24 03:36:58 2006 +0000 2006-06-24 2006-06-24 03:36:58 stat modify ignore properties on directory --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40304 +9b41b12902a1f12d90839d5aa12b49a29617e642 SanketDG sanketdasgupta@gmail.com gmail Thu Mar 5 21:42:17 2015 +0530 2015-03-05 2015-03-05 16:12:17 stat 1 file changed, 2 insertions(+), 2 deletions(-) 1 2 2 fix tests by adapting new functions networkx/algorithms/bipartite/tests/test_basic.py networkx/algorithms/bipartite/tests/test_basic.py | 4 ++-- +aa9374e0d3296eff68dfcced7bc8009180890e77 Himanshu Mishra himanshu2014iit@gmail.com gmail Sat Jul 11 20:02:04 2015 +0530 2015-07-11 2015-07-11 14:32:04 stat 1 file changed, 13 insertions(+), 14 deletions(-) 1 13 14 Switch to container based travis build .travis.yml .travis.yml | 27 +++++++++++++-------------- +71461a3083e5b57779a98696890f5f177f13a5cb ysitu ysitu@users.noreply.github.com users.noreply.github Sun Apr 20 10:10:50 2014 -0400 2014-04-20 2014-04-20 14:10:50 stat 1 file changed, 9 insertions(+), 2 deletions(-) 1 9 2 Fix python2.6 compatibility networkx/utils/tests/test_heaps.py networkx/utils/tests/test_heaps.py | 11 +++++++++-- +4301a78b1df19967078b7ce94a505202111dbee4 chebee7i chebee7i@gmail.com gmail Thu Sep 26 14:54:59 2013 -0500 2013-09-26 2013-09-26 19:54:59 stat 1 file changed, 2 insertions(+) 1 2 Update travisCI configuration to install networkx first. .travis.yml .travis.yml | 2 ++ +7f876b295546b529793198657fd262c5a782e5d3 aric none@none None Thu Apr 22 22:26:44 2010 +0000 2010-04-22 2010-04-22 22:26:44 stat 3 files changed, 16 insertions(+), 11 deletions(-) 3 16 11 Adjust tests and operators to work with Python2.4 --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401727 .../centrality/tests/test_betweenness_centrality.py;networkx/algorithms/operators.py;networkx/algorithms/tests/test_mixing_degree.py .../centrality/tests/test_betweenness_centrality.py | 8 ++++----;networkx/algorithms/operators.py | 17 +++++++++++------;networkx/algorithms/tests/test_mixing_degree.py | 2 +- +a97e263cff7fca6b72b57eb2451cbfba9cb0cf46 aric none@none None Wed Oct 21 12:08:19 2009 +0000 2009-10-21 2009-10-21 12:08:19 stat 2 files changed, 15 insertions(+), 2 deletions(-) 2 15 2 Fix bug in eigenvector centrality for unweighted graphs. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401488 networkx/algorithms/centrality.py;networkx/algorithms/tests/test_eigenvector_centrality.py networkx/algorithms/centrality.py | 2 +-;networkx/algorithms/tests/test_eigenvector_centrality.py | 15 ++++++++++++++- +0c3c017995bb4dbeb131a877c9f99ac32628ab8d aric none@none None Wed Feb 8 22:20:49 2006 +0000 2006-02-08 2006-02-08 22:20:49 stat 1 file changed, 4 insertions(+), 4 deletions(-) 1 4 4 add option to construct graph laplacian with rows/columns in a specific ordering --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40159 networkx/spectrum.py networkx/spectrum.py | 8 ++++---- +0ef4bb9a1d0d4899d1c675b81f584bb9506be54c aric none@none None Wed Aug 30 02:54:40 2006 +0000 2006-08-30 2006-08-30 02:54:40 stat 1 file changed, 2 insertions(+), 2 deletions(-) 1 2 2 M classic.py allow create_using for complete_graph() --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40383 networkx/generators/classic.py networkx/generators/classic.py | 4 ++-- +35830058d50e2e5cb8a54cbf166c28b5720b0b81 Aric Hagberg aric.hagberg@gmail.com gmail Wed Jan 13 09:45:18 2016 -0700 2016-01-13 2016-01-13 16:45:18 stat 1 file changed, 13 insertions(+) 1 13 Add tests for empty edges and duplicate edges networkx/testing/tests/test_utils.py networkx/testing/tests/test_utils.py | 13 +++++++++++++ +b79f16053f12d588161a3091c531abdef3b14974 Aric Hagberg aric.hagberg@gmail.com gmail Sun Mar 8 10:47:05 2015 -0600 2015-03-08 2015-03-08 16:47:05 stat 7 files changed, 837 insertions(+), 84 deletions(-) 7 837 84 Merge bipartite reader/writer, adj matrix networkx/algorithms/bipartite/__init__.py;networkx/algorithms/bipartite/basic.py;networkx/algorithms/bipartite/edgelist.py;networkx/algorithms/bipartite/matrix.py;networkx/algorithms/bipartite/tests/test_basic.py;.../algorithms/bipartite/tests/test_edgelist.py;networkx/algorithms/bipartite/tests/test_matrix.py networkx/algorithms/bipartite/__init__.py | 4 +-;networkx/algorithms/bipartite/basic.py | 85 +----;networkx/algorithms/bipartite/edgelist.py | 360 +++++++++++++++++++++;networkx/algorithms/bipartite/matrix.py | 177 ++++++++++;networkx/algorithms/bipartite/tests/test_basic.py | 1 +;.../algorithms/bipartite/tests/test_edgelist.py | 204 ++++++++++++;networkx/algorithms/bipartite/tests/test_matrix.py | 90 ++++++ +023a7c7d4e05643031beabe4a566595ec0bed94b Aric Hagberg aric.hagberg@gmail.com gmail Sun Sep 1 07:24:41 2013 -0700 2013-09-01 2013-09-01 14:24:41 stat ac8571a 3f75de0 Merge pull request #934 from jtorrents/est-avg-clust-coeff Add approximation for average clustering coefficient +8358afac209c00b7feb3e81c901098852a9413b3 Aric Hagberg aric.hagberg@gmail.com gmail Sat Jun 13 14:37:03 2015 -0600 2015-06-13 2015-06-13 20:37:03 stat 1 file changed, 1 insertion(+), 2 deletions(-) 1 1 2 Bad indent networkx/algorithms/dag.py networkx/algorithms/dag.py | 3 +-- +47565b1131a98f332123bd6423019b3d9a9bae71 Aric Hagberg aric.hagberg@gmail.com gmail Mon Jun 18 17:24:24 2012 -0600 2012-06-18 2012-06-18 23:24:24 stat 2 files changed, 11 insertions(+), 3 deletions(-) 2 11 3 Handle name in translation between pygraphviz (AGraph) and networkx. Fixes #734 networkx/drawing/nx_agraph.py;networkx/drawing/tests/test_agraph.py networkx/drawing/nx_agraph.py | 5 ++++-;networkx/drawing/tests/test_agraph.py | 9 +++++++-- +54ddf1fb6de8555cd7edb4b1b3138243a7f72163 ysitu ysitu@users.noreply.github.com users.noreply.github Mon Mar 24 23:17:53 2014 -0400 2014-03-25 2014-03-25 03:17:53 stat 1 file changed, 8 insertions(+), 4 deletions(-) 1 8 4 Fix max_height calculation in global_relabel in preflow-push maxflow networkx/algorithms/flow/preflow_push.py networkx/algorithms/flow/preflow_push.py | 12 ++++++++---- +159722d6f52be6aaff58d82778c62bb996cec400 Aric Hagberg aric.hagberg@gmail.com gmail Mon Dec 26 11:06:16 2011 -0700 2011-12-26 2011-12-26 18:06:16 stat 6 files changed, 124 insertions(+), 153 deletions(-) 6 124 153 Some whitespace and formatting housekeeping networkx/algorithms/link_analysis/pagerank_alg.py;.../link_analysis/tests/test_pagerank.py;networkx/convert.py;networkx/drawing/layout.py;networkx/drawing/tests/test_layout.py;networkx/tests/test_convert_scipy.py networkx/algorithms/link_analysis/pagerank_alg.py | 6 +-;.../link_analysis/tests/test_pagerank.py | 13 +--;networkx/convert.py | 110 ++++++++++-----------;networkx/drawing/layout.py | 98 +++++++++---------;networkx/drawing/tests/test_layout.py | 9 +-;networkx/tests/test_convert_scipy.py | 41 ++++---- +43eb4f930f14fcf693f0656a3f0bbe749ed98d2e Jordi Torrents jordi.t21@gmail.com gmail Sun May 10 17:06:20 2015 +0200 2015-05-10 2015-05-10 15:06:20 stat 1 file changed, 84 insertions(+) 1 84 Move subgraph attribute copies tests to a separate file. .../components/tests/test_subgraph_copies.py .../components/tests/test_subgraph_copies.py | 84 ++++++++++++++++++++++ +bf050813172905b5760d856d174d8ae1a3e2c547 ysitu ysitu@users.noreply.github.com users.noreply.github Fri May 30 21:59:59 2014 -0400 2014-05-31 2014-05-31 01:59:59 stat 1 file changed, 3 insertions(+), 3 deletions(-) 1 3 3 Update release URLs and development status networkx/release.py networkx/release.py | 6 +++--- +be778b351e6b6af18a786265851142a1b9dd420a aric none@none None Tue Apr 28 18:59:13 2009 +0000 2009-04-28 2009-04-28 18:59:13 stat 1 file changed, 1 insertion(+), 1 deletion(-) 1 1 1 remove erroneous quotes in isinstance() --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401193 networkx/classes/labeledgraph.py networkx/classes/labeledgraph.py | 2 +- +8f398aca99c39829ed268a5f5121eb663eb73955 aric none@none None Sat Jan 16 13:35:02 2010 +0000 2010-01-16 2010-01-16 13:35:02 stat 1 file changed, 11 insertions(+), 6 deletions(-) 1 11 6 Use 1/len(G) for starting vector entries. Add example. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401517 networkx/algorithms/centrality.py networkx/algorithms/centrality.py | 17 +++++++++++------ +a9f3345154341c2269dc752fab66002905d03214 aric none@none None Thu Apr 12 04:34:18 2007 +0000 2007-04-12 2007-04-12 04:34:18 stat 3 files changed, 51 insertions(+), 48 deletions(-) 3 51 48 update News,Contributing,Credits --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40566 doc/Contributing.txt;doc/Credits.txt;doc/News.txt doc/Contributing.txt | 61 +++++++++++-----------------------------------------;doc/Credits.txt | 1 +;doc/News.txt | 37 +++++++++++++++++++++++++++++++ +620d54fcfd881aaa262fb2a4ef350c312db83884 Loïc Séguin-C. loicseguin@gmail.com gmail Wed Feb 9 22:56:34 2011 -0500 2011-02-10 2011-02-10 03:56:34 stat 9 files changed, 8 insertions(+), 13 deletions(-) 9 8 13 Cleaned up import statements. networkx/readwrite/adjlist.py;networkx/readwrite/edgelist.py;networkx/readwrite/gml.py;networkx/readwrite/gpickle.py;networkx/readwrite/multiline_adjlist.py;networkx/readwrite/sparsegraph6.py;networkx/release.py;networkx/tests/test_convert_numpy.py;networkx/tests/test_convert_scipy.py networkx/readwrite/adjlist.py | 2 +-;networkx/readwrite/edgelist.py | 2 +-;networkx/readwrite/gml.py | 2 +-;networkx/readwrite/gpickle.py | 2 +-;networkx/readwrite/multiline_adjlist.py | 2 +-;networkx/readwrite/sparsegraph6.py | 2 +-;networkx/release.py | 1 -;networkx/tests/test_convert_numpy.py | 4 +---;networkx/tests/test_convert_scipy.py | 4 +--- +6b08e39d999c902781d82c990bf9c3555226eb94 Brandon Liu brandon.k.liu@gmail.com gmail Sat Nov 2 15:43:41 2013 -0400 2013-11-02 2013-11-02 19:43:41 stat 1 file changed, 9 insertions(+), 6 deletions(-) 1 9 6 Add numpy guard to tests networkx/algorithms/link_analysis/tests/test_pagerank.py networkx/algorithms/link_analysis/tests/test_pagerank.py | 15 +++++++++------ +f9fc3b4e62032e48ddce0821cfe2ffc27c6756d1 Chris Ellison cellison@cse.ucdavis.edu cse.ucdavis Fri Jan 6 11:53:40 2012 -0500 2012-01-06 2012-01-06 16:53:40 stat 1 file changed, 3 deletions(-) 1 3 Remove except clause from open_file decorator. Addresses #672 networkx/utils/decorators.py networkx/utils/decorators.py | 3 --- +affbefd05c19cfd40ecb544b393817d082ca2904 aric none@none None Wed Feb 18 04:54:16 2009 +0000 2009-02-18 2009-02-18 04:54:16 stat 1 file changed, 60 insertions(+), 42 deletions(-) 1 60 42 lazyImport numpy and scipy in convert Set default type of numpy and scipy matrices returned to be float32 and add keyword option to change type. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401155 networkx/convert.py networkx/convert.py | 102 ++++++++++++++++++++++++++++++---------------------- +c1f059380b499da5375b5ecea5a6b67812ea59ef chebee7i chebee7i@gmail.com gmail Wed May 21 17:14:36 2014 -0500 2014-05-21 2014-05-21 22:14:36 stat 2 files changed, 16 insertions(+), 8 deletions(-) 2 16 8 Provide replacements if BLAS not available from SciPy. networkx/linalg/algebraicconnectivity.py;networkx/linalg/tests/test_algebraic_connectivity.py networkx/linalg/algebraicconnectivity.py | 16 +++++++++++++++-;networkx/linalg/tests/test_algebraic_connectivity.py | 8 +------- +3fa8b7018f096d8f2e34db91372c95dc5d190443 aric none@none None Mon Aug 9 15:25:31 2010 +0000 2010-08-09 2010-08-09 15:25:31 stat 2 files changed, 62 insertions(+), 62 deletions(-) 2 62 62 Use unittest style --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401888 networkx/algorithms/tests/dag.txt;networkx/algorithms/tests/test_dag.py networkx/algorithms/tests/dag.txt | 62 -----------------------------------;networkx/algorithms/tests/test_dag.py | 62 +++++++++++++++++++++++++++++++++++ +f73b1c28cc88ed36bc2689d3cd262279c6903012 Aric Hagberg aric.hagberg@gmail.com gmail Thu Jan 13 21:32:41 2011 -0700 2011-01-14 2011-01-14 04:32:41 stat 1 file changed, 55 insertions(+), 3 deletions(-) 1 55 3 Add string option with generate_gexf() Addresses #489 networkx/readwrite/gexf.py networkx/readwrite/gexf.py | 58 +++++++++++++++++++++++++++++++++++++++++++--- +0d40a0596c3adadedcc96e9ed964d871cbc44fec Georg Walther georgwalther@gmail.com gmail Fri Dec 6 00:37:48 2013 +0000 2013-12-06 2013-12-06 00:37:48 stat 1 file changed, 13 insertions(+), 13 deletions(-) 1 13 13 move helper function into get_all_cliques networkx/algorithms/clique.py networkx/algorithms/clique.py | 26 +++++++++++++------------- +ba9a828f4a121cb3c56c3aa79cd9c6773cd883f5 Jordi Torrents jordi.t21@gmail.com gmail Sun Apr 13 18:05:08 2014 +0200 2014-04-13 2014-04-13 16:05:08 stat 2 files changed, 108 insertions(+), 9 deletions(-) 2 108 9 Add edmonds_karp_residual function, and edmonds_karp* to tests. networkx/algorithms/flow/edmonds_karp.py;networkx/algorithms/flow/tests/test_maxflow.py networkx/algorithms/flow/edmonds_karp.py | 103 ++++++++++++++++++++++++-;networkx/algorithms/flow/tests/test_maxflow.py | 14 ++-- +8e49a4d463b2068f000b74cc3929113a491c725b Aric Hagberg aric.hagberg@gmail.com gmail Mon Aug 1 14:16:44 2011 -0600 2011-08-01 2011-08-01 20:16:44 stat 1 file changed, 26 insertions(+), 23 deletions(-) 1 26 23 Decorators don't pass doctests - comment them out. networkx/utils/decorators.py networkx/utils/decorators.py | 49 +++++++++++++++++++++++--------------------- +9372eb2857e5b38faf1d1dd0f22b56421faa72c2 aric none@none None Sat Aug 7 14:16:53 2010 +0000 2010-08-07 2010-08-07 14:16:53 stat 1 file changed, 3 insertions(+), 3 deletions(-) 1 3 3 |V| notation breaks the sphinx build as missing reference --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401865 networkx/algorithms/flow/maxflow.py networkx/algorithms/flow/maxflow.py | 6 +++--- +746445595b0463f1994055442a627ce80b58241e Aric Hagberg aric.hagberg@gmail.com gmail Sun Jul 28 07:16:00 2013 -0700 2013-07-28 2013-07-28 14:16:00 stat 7d9682a e33ed2b Merge pull request #917 from hagberg/master Update README year +a9e6e645737ca7d22616d63c7b7e45b682d55b72 aric none@none None Thu Dec 31 23:20:26 2009 +0000 2009-12-31 2009-12-31 23:20:26 stat 1 file changed, 1 insertion(+), 5 deletions(-) 1 1 5 Remove create_using keyword from read_dot() Fixes #303 --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401498 networkx/drawing/nx_agraph.py networkx/drawing/nx_agraph.py | 6 +----- +ea6b2f524bcca48a18132cc85a7be2d926faab44 tdihp tdihp@hotmail.com hotmail Wed Jun 5 10:30:15 2013 +0800 2013-06-05 2013-06-05 02:30:15 stat 1 file changed, 1 insertion(+), 1 deletion(-) 1 1 1 single_source_dijkstra_path passes cutoff networkx/algorithms/shortest_paths/weighted.py networkx/algorithms/shortest_paths/weighted.py | 2 +- +75ea153e8ef89c8e95ef5682c59ccba427c40bd2 aric none@none None Fri Jul 15 00:10:33 2005 +0000 2005-07-15 2005-07-15 00:10:33 stat 118 files changed, 6529 insertions(+), 6527 deletions(-) 118 6529 6527 Move testing directory up one level. Adjust paths for tests in every module. --HG-- rename : networkx/tests/.cvsignore => tests/.cvsignore rename : networkx/tests/Makefile => tests/Makefile rename : networkx/tests/README => tests/README rename : networkx/tests/__init__.py => tests/__init__.py rename : networkx/tests/base_DiGraph.txt => tests/base_DiGraph.txt rename : networkx/tests/base_Graph.txt => tests/base_Graph.txt rename : networkx/tests/centrality.txt => tests/centrality.txt rename : networkx/tests/cliques.txt => tests/cliques.txt rename : networkx/tests/cluster.txt => tests/cluster.txt rename : networkx/tests/cores.txt => tests/cores.txt rename : networkx/tests/data/base_PseudoGraph_G.png => tests/data/base_PseudoGraph_G.png rename : networkx/tests/data/base_PseudoGraph_K.png => tests/data/base_PseudoGraph_K.png rename : networkx/tests/data/cores_Batagelj_example.png => tests/data/cores_Batagelj_example.png rename : networkx/tests/data/cores_H.png => tests/data/cores_H.png rename : networkx/tests/data/nx_doctest.css => tests/data/nx_doctest.css rename : networkx/tests/data/paths_G.png => tests/data/paths_G.png rename : networkx/tests/data/xbase_XDiGraph_G.png => tests/data/xbase_XDiGraph_G.png rename : networkx/tests/data/xbase_XDiGraph_Z.png => tests/data/xbase_XDiGraph_Z.png rename : networkx/tests/data/xbase_XDiGraph_Zm.png => tests/data/xbase_XDiGraph_Zm.png rename : networkx/tests/data/xbase_XDiGraph_Zms.png => tests/data/xbase_XDiGraph_Zms.png rename : networkx/tests/data/xbase_XDiGraph_Zs.png => tests/data/xbase_XDiGraph_Zs.png rename : networkx/tests/generators_atlas.txt => tests/generators_atlas.txt rename : networkx/tests/generators_classic.txt => tests/generators_classic.txt rename : networkx/tests/generators_degree_seq.txt => tests/generators_degree_seq.txt rename : networkx/tests/generators_geometric.txt => tests/generators_geometric.txt rename : networkx/tests/generators_random_graphs.txt => tests/generators_random_graphs.txt rename : networkx/tests/generators_small.txt => tests/generators_small.txt rename : networkx/tests/hybrid.txt => tests/hybrid.txt rename : networkx/tests/io.txt => tests/io.txt rename : networkx/tests/isomorph.txt => tests/isomorph.txt rename : networkx/tests/layout.txt => tests/layout.txt rename : networkx/tests/nx_pydot.txt => tests/nx_pydot.txt rename : networkx/tests/nx_pylab.txt => tests/nx_pylab.txt rename : networkx/tests/operators.txt => tests/operators.txt rename : networkx/tests/paths.txt => tests/paths.txt rename : networkx/tests/queues.txt => tests/queues.txt rename : networkx/tests/search.txt => tests/search.txt rename : networkx/tests/search_class.txt => tests/search_class.txt rename : networkx/tests/spectrum.txt => tests/spectrum.txt rename : networkx/tests/test.py => tests/test.py rename : networkx/tests/test2.py => tests/test2.py rename : networkx/tests/threshold.txt => tests/threshold.txt rename : networkx/tests/utils.txt => tests/utils.txt rename : networkx/tests/xbase_DiGraph.txt => tests/xbase_DiGraph.txt rename : networkx/tests/xbase_Graph.txt => tests/xbase_Graph.txt rename : networkx/tests/xbase_PseudoGraph.txt => tests/xbase_PseudoGraph.txt extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%4014 networkx/base.py;networkx/centrality.py;networkx/cliques.py;networkx/cluster.py;networkx/cores.py;networkx/drawing/layout.py;networkx/drawing/nx_pydot.py;networkx/drawing/nx_pylab.py;networkx/generators/atlas.py;networkx/generators/classic.py;networkx/generators/degree_seq.py;networkx/generators/geometric.py;networkx/generators/random_graphs.py;networkx/generators/small.py;networkx/hybrid.py;networkx/io.py;networkx/isomorph.py;networkx/operators.py;networkx/paths.py;networkx/queues.py;networkx/search.py;networkx/search_class.py;networkx/spectrum.py;networkx/tests/.cvsignore;networkx/tests/Makefile;networkx/tests/README;networkx/tests/__init__.py;networkx/tests/base_DiGraph.txt;networkx/tests/base_Graph.txt;networkx/tests/centrality.txt;networkx/tests/cliques.txt;networkx/tests/cluster.txt;networkx/tests/cores.txt;networkx/tests/data/base_PseudoGraph_G.png;networkx/tests/data/base_PseudoGraph_K.png;networkx/tests/data/cores_Batagelj_example.png;networkx/tests/data/cores_H.png;networkx/tests/data/nx_doctest.css;networkx/tests/data/paths_G.png;networkx/tests/data/xbase_XDiGraph_G.png;networkx/tests/data/xbase_XDiGraph_Z.png;networkx/tests/data/xbase_XDiGraph_Zm.png;networkx/tests/data/xbase_XDiGraph_Zms.png;networkx/tests/data/xbase_XDiGraph_Zs.png;networkx/tests/generators_atlas.txt;networkx/tests/generators_classic.txt;networkx/tests/generators_degree_seq.txt;networkx/tests/generators_geometric.txt;networkx/tests/generators_random_graphs.txt;networkx/tests/generators_small.txt;networkx/tests/hybrid.txt;networkx/tests/io.txt;networkx/tests/isomorph.txt;networkx/tests/layout.txt;networkx/tests/nx_pydot.txt;networkx/tests/nx_pylab.txt;networkx/tests/operators.txt;networkx/tests/paths.txt;networkx/tests/queues.txt;networkx/tests/search.txt;networkx/tests/search_class.txt;networkx/tests/spectrum.txt;networkx/tests/test.py;networkx/tests/test2.py;networkx/tests/threshold.txt;networkx/tests/utils.txt;networkx/tests/xbase_DiGraph.txt;networkx/tests/xbase_Graph.txt;networkx/tests/xbase_PseudoGraph.txt;networkx/threshold.py;networkx/utils.py;networkx/xbase.py;tests/.cvsignore;tests/Makefile;tests/README;tests/__init__.py;tests/base_DiGraph.txt;tests/base_Graph.txt;tests/centrality.txt;tests/cliques.txt;tests/cluster.txt;tests/cores.txt;tests/data/base_PseudoGraph_G.png;tests/data/base_PseudoGraph_K.png;tests/data/cores_Batagelj_example.png;tests/data/cores_H.png;tests/data/nx_doctest.css;tests/data/paths_G.png;tests/data/xbase_XDiGraph_G.png;tests/data/xbase_XDiGraph_Z.png;tests/data/xbase_XDiGraph_Zm.png;tests/data/xbase_XDiGraph_Zms.png;tests/data/xbase_XDiGraph_Zs.png;tests/generators_atlas.txt;tests/generators_classic.txt;tests/generators_degree_seq.txt;tests/generators_geometric.txt;tests/generators_random_graphs.txt;tests/generators_small.txt;tests/hybrid.txt;tests/io.txt;tests/isomorph.txt;tests/layout.txt;tests/nx_pydot.txt;tests/nx_pylab.txt;tests/operators.txt;tests/paths.txt;tests/queues.txt;tests/search.txt;tests/search_class.txt;tests/spectrum.txt;tests/test.py;tests/test2.py;tests/threshold.txt;tests/utils.txt;tests/xbase_DiGraph.txt;tests/xbase_Graph.txt;tests/xbase_PseudoGraph.txt networkx/base.py | 4 +-;networkx/centrality.py | 2 +-;networkx/cliques.py | 2 +-;networkx/cluster.py | 2 +-;networkx/cores.py | 3 +-;networkx/drawing/layout.py | 2 +-;networkx/drawing/nx_pydot.py | 2 +-;networkx/drawing/nx_pylab.py | 2 +-;networkx/generators/atlas.py | 2 +-;networkx/generators/classic.py | 2 +-;networkx/generators/degree_seq.py | 2 +-;networkx/generators/geometric.py | 2 +-;networkx/generators/random_graphs.py | 2 +-;networkx/generators/small.py | 2 +-;networkx/hybrid.py | 2 +-;networkx/io.py | 2 +-;networkx/isomorph.py | 2 +-;networkx/operators.py | 2 +-;networkx/paths.py | 2 +-;networkx/queues.py | 2 +-;networkx/search.py | 3 +-;networkx/search_class.py | 2 +-;networkx/spectrum.py | 2 +-;networkx/tests/.cvsignore | 3 -;networkx/tests/Makefile | 28 -;networkx/tests/README | 13 -;networkx/tests/__init__.py | 0;networkx/tests/base_DiGraph.txt | 726 ---------------------;networkx/tests/base_Graph.txt | 772 -----------------------;networkx/tests/centrality.txt | 63 --;networkx/tests/cliques.txt | 83 ---;networkx/tests/cluster.txt | 90 ---;networkx/tests/cores.txt | 62 --;networkx/tests/data/base_PseudoGraph_G.png | Bin 2644 -> 0 bytes;networkx/tests/data/base_PseudoGraph_K.png | Bin 1625 -> 0 bytes;networkx/tests/data/cores_Batagelj_example.png | Bin 6961 -> 0 bytes;networkx/tests/data/cores_H.png | Bin 2114 -> 0 bytes;networkx/tests/data/nx_doctest.css | 104 ---;networkx/tests/data/paths_G.png | Bin 32652 -> 0 bytes;networkx/tests/data/xbase_XDiGraph_G.png | Bin 2620 -> 0 bytes;networkx/tests/data/xbase_XDiGraph_Z.png | Bin 5964 -> 0 bytes;networkx/tests/data/xbase_XDiGraph_Zm.png | Bin 9024 -> 0 bytes;networkx/tests/data/xbase_XDiGraph_Zms.png | Bin 11096 -> 0 bytes;networkx/tests/data/xbase_XDiGraph_Zs.png | Bin 7823 -> 0 bytes;networkx/tests/generators_atlas.txt | 12 -;networkx/tests/generators_classic.txt | 614 ------------------;networkx/tests/generators_degree_seq.txt | 114 ----;networkx/tests/generators_geometric.txt | 7 -;networkx/tests/generators_random_graphs.txt | 28 -;networkx/tests/generators_small.txt | 292 ---------;networkx/tests/hybrid.txt | 32 -;networkx/tests/io.txt | 62 --;networkx/tests/isomorph.txt | 28 -;networkx/tests/layout.txt | 13 -;networkx/tests/nx_pydot.txt | 93 ---;networkx/tests/nx_pylab.txt | 42 --;networkx/tests/operators.txt | 335 ----------;networkx/tests/paths.txt | 146 -----;networkx/tests/queues.txt | 17 -;networkx/tests/search.txt | 54 --;networkx/tests/search_class.txt | 43 --;networkx/tests/spectrum.txt | 56 --;networkx/tests/test.py | 80 ---;networkx/tests/test2.py | 46 --;networkx/tests/threshold.txt | 148 -----;networkx/tests/utils.txt | 55 --;networkx/tests/xbase_DiGraph.txt | 836 -------------------------;networkx/tests/xbase_Graph.txt | 668 --------------------;networkx/tests/xbase_PseudoGraph.txt | 731 ---------------------;networkx/threshold.py | 3 +-;networkx/utils.py | 2 +-;networkx/xbase.py | 6 +-;tests/.cvsignore | 3 +;tests/Makefile | 28 +;tests/README | 13 +;tests/__init__.py | 0;tests/base_DiGraph.txt | 726 +++++++++++++++++++++;tests/base_Graph.txt | 772 +++++++++++++++++++++++;tests/centrality.txt | 63 ++;tests/cliques.txt | 83 +++;tests/cluster.txt | 90 +++;tests/cores.txt | 62 ++;tests/data/base_PseudoGraph_G.png | Bin 0 -> 2644 bytes;tests/data/base_PseudoGraph_K.png | Bin 0 -> 1625 bytes;tests/data/cores_Batagelj_example.png | Bin 0 -> 6961 bytes;tests/data/cores_H.png | Bin 0 -> 2114 bytes;tests/data/nx_doctest.css | 104 +++;tests/data/paths_G.png | Bin 0 -> 32652 bytes;tests/data/xbase_XDiGraph_G.png | Bin 0 -> 2620 bytes;tests/data/xbase_XDiGraph_Z.png | Bin 0 -> 5964 bytes;tests/data/xbase_XDiGraph_Zm.png | Bin 0 -> 9024 bytes;tests/data/xbase_XDiGraph_Zms.png | Bin 0 -> 11096 bytes;tests/data/xbase_XDiGraph_Zs.png | Bin 0 -> 7823 bytes;tests/generators_atlas.txt | 12 +;tests/generators_classic.txt | 614 ++++++++++++++++++;tests/generators_degree_seq.txt | 114 ++++;tests/generators_geometric.txt | 7 +;tests/generators_random_graphs.txt | 28 +;tests/generators_small.txt | 292 +++++++++;tests/hybrid.txt | 32 +;tests/io.txt | 62 ++;tests/isomorph.txt | 28 +;tests/layout.txt | 13 +;tests/nx_pydot.txt | 93 +++;tests/nx_pylab.txt | 42 ++;tests/operators.txt | 335 ++++++++++;tests/paths.txt | 146 +++++;tests/queues.txt | 17 +;tests/search.txt | 54 ++;tests/search_class.txt | 43 ++;tests/spectrum.txt | 56 ++;tests/test.py | 83 +++;tests/test2.py | 46 ++;tests/threshold.txt | 148 +++++;tests/utils.txt | 55 ++;tests/xbase_DiGraph.txt | 836 +++++++++++++++++++++++++;tests/xbase_Graph.txt | 668 ++++++++++++++++++++;tests/xbase_PseudoGraph.txt | 731 +++++++++++++++++++++ +5404d3956aa006784a1f2f23f107e623ad07ff57 Aric Hagberg aric.hagberg@gmail.com gmail Sun Jul 17 09:56:10 2011 -0600 2011-07-17 2011-07-17 15:56:10 stat 2 files changed, 7 insertions(+), 3 deletions(-) 2 7 3 Don't allow running networkx.test() if the current working directory is the networkx source root. networkx/tests/test.py;setup.cfg networkx/tests/test.py | 8 ++++++--;setup.cfg | 2 +- +e6e83fe5b9038e9974b0bc59f74370fe427bc4d9 Aric Hagberg aric.hagberg@gmail.com gmail Sat Dec 29 06:35:27 2012 -0800 2012-12-29 2012-12-29 14:35:27 stat 9632297 5dc8f93 Merge pull request #802 from hagberg/skip-scipy Skip tests if scipy not installed. +b83a37a6d0f1908d2124c772b3ed3e7453409e66 cellison none@none None Mon May 4 02:13:50 2009 +0000 2009-05-04 2009-05-04 02:13:50 stat 1 file changed, 24 insertions(+), 12 deletions(-) 1 24 12 removing __del__ methods addressing memory leak. fixes #242. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401195 networkx/algorithms/isomorphism/isomorphvf2.py networkx/algorithms/isomorphism/isomorphvf2.py | 36 +++++++++++++++++--------- +af39162e0342a94af1e5b53678e2ff3fbed8198c Aric Hagberg aric.hagberg@gmail.com gmail Mon May 9 08:10:16 2011 -0600 2011-05-09 2011-05-09 14:10:16 stat 2 files changed, 6 insertions(+), 1 deletion(-) 2 6 1 Handle out-degree zero nodes. Addresses #548 networkx/algorithms/bipartite/basic.py;networkx/algorithms/bipartite/tests/test_basic.py networkx/algorithms/bipartite/basic.py | 4 +++-;networkx/algorithms/bipartite/tests/test_basic.py | 3 +++ +2b3f7e27a0e87a52ac8049c9e3665327e8770bcf aric none@none None Sat Nov 15 22:19:27 2008 +0000 2008-11-15 2008-11-15 22:19:27 stat 1 file changed, 3 insertions(+), 3 deletions(-) 1 3 3 update plugin to work with nose-0.11 --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40993 nose_plugin/setup.py nose_plugin/setup.py | 6 +++--- +88cf4e98faee162a1f7aed7d2d48844bff0865db aric none@none None Tue Apr 6 04:36:56 2010 +0000 2010-04-06 2010-04-06 04:36:56 stat 4 files changed, 65 insertions(+), 21 deletions(-) 4 65 21 Add more documentation on shallow and deep copies --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401658 networkx/classes/digraph.py;networkx/classes/graph.py;networkx/classes/multidigraph.py;networkx/classes/multigraph.py networkx/classes/digraph.py | 25 +++++++++++++++++++------;networkx/classes/graph.py | 24 ++++++++++++++++++------;networkx/classes/multidigraph.py | 24 ++++++++++++++++++------;networkx/classes/multigraph.py | 13 ++++++++++--- +996713761315239d997011579d1b84871bbb3423 Aric Hagberg aric.hagberg@gmail.com gmail Sun Oct 17 14:00:53 2010 -0600 2010-10-17 2010-10-17 20:00:53 stat 2 files changed, 13 insertions(+), 11 deletions(-) 2 13 11 Bugfix in dfs postorder. Adjust tests for new interface. Addresses #418 networkx/algorithms/traversal/depth_first_search.py;networkx/algorithms/traversal/tests/test_dfs.py networkx/algorithms/traversal/depth_first_search.py | 6 +++---;networkx/algorithms/traversal/tests/test_dfs.py | 18 ++++++++++-------- +33a9b0ab7cb41386d2f08ed5ddfb5584dea32c71 Aric Hagberg aric.hagberg@gmail.com gmail Mon Jul 22 11:40:03 2013 -0600 2013-07-22 2013-07-22 17:40:03 stat 3 files changed, 4 insertions(+), 3 deletions(-) 3 4 3 API changes, update news doc/source/reference/api_1.8.rst;doc/source/reference/api_changes.rst;doc/source/reference/news.rst doc/source/reference/api_1.8.rst | 4 +++-;doc/source/reference/api_changes.rst | 1 +;doc/source/reference/news.rst | 2 -- +dd63fed4840a006db8a5cf11e2a93bdbd9121af1 Jan Aagaard Meier janzeh@gmail.com gmail Mon May 5 20:03:28 2014 +0200 2014-05-05 2014-05-05 18:03:28 stat 2 files changed, 54 insertions(+), 59 deletions(-) 2 54 59 Renamed the entry point in greedy_coloring to greedy_color, to avoid having to write greedy_coloring.greedy_coloring networkx/algorithms/coloring/greedy_coloring.py;.../algorithms/coloring/tests/test_coloring.py networkx/algorithms/coloring/greedy_coloring.py | 11 +--;.../algorithms/coloring/tests/test_coloring.py | 102 ++++++++++----------- +8bc1e80ed346da3a8e5780b4039ffc0a0ee76fa1 Brandon Liu brandon.k.liu@gmail.com gmail Sun Oct 27 22:43:30 2013 -0400 2013-10-28 2013-10-28 02:43:30 stat 1 file changed, 6 insertions(+), 6 deletions(-) 1 6 6 Variable name improvements networkx/algorithms/link_analysis/pagerank_alg.py networkx/algorithms/link_analysis/pagerank_alg.py | 12 ++++++------ +dfc16964c525002ef1e3859583ca360488d2681e aric none@none None Wed Aug 19 16:20:42 2009 +0000 2009-08-19 2009-08-19 16:20:42 stat 3 files changed, 15 insertions(+), 9 deletions(-) 3 15 9 Adjust contents for reference guide --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401419 doc/source/conf.py;doc/source/reference/index.rst;doc/source/reference/introduction.rst doc/source/conf.py | 4 +---;doc/source/reference/index.rst | 8 ++++++++;doc/source/reference/introduction.rst | 12 ++++++------ +c5f2eeb9de461e87d4a07fb476d11cce2fe61c08 dschult none@none None Sat Jan 7 04:57:53 2006 +0000 2006-01-07 2006-01-07 04:57:53 stat 1 file changed, 8 insertions(+), 2 deletions(-) 1 8 2 Fix for bug #22 --- get_edge now returns a copy of the list of edge data when using multiedges. --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%40131 networkx/xbase.py networkx/xbase.py | 10 ++++++++-- +6d0d2f1124293344e32f67e27ebcd93b68ff01c7 Aric Hagberg aric.hagberg@gmail.com gmail Wed Jan 13 09:42:58 2016 -0700 2016-01-13 2016-01-13 16:42:58 stat 1 file changed, 9 insertions(+), 18 deletions(-) 1 9 18 Test for number of edges, simplify assert_graphs_equal networkx/testing/utils.py networkx/testing/utils.py | 27 +++++++++------------------ +8cf2b96b2fb6d7173bce7b562f8e67661857d0c1 ysitu ysitu@users.noreply.github.com users.noreply.github Wed Jun 25 19:27:08 2014 -0400 2014-06-25 2014-06-25 23:27:08 stat 4 files changed, 14 insertions(+), 14 deletions(-) 4 14 14 Adapt print statements in examples for Python 3 compatibility examples/algorithms/rcm.py;examples/drawing/giant_component.py;examples/drawing/lanl_routes.py;examples/pygraphviz/write_dotfile.py examples/algorithms/rcm.py | 6 +++---;examples/drawing/giant_component.py | 2 +-;examples/drawing/lanl_routes.py | 8 ++++----;examples/pygraphviz/write_dotfile.py | 12 ++++++------ +bccec95fd331cc80b6772163a8f6feaf4e823647 Aric Hagberg aric.hagberg@gmail.com gmail Wed May 6 09:01:33 2015 -0600 2015-05-06 2015-05-06 15:01:33 stat 3 files changed, 93 insertions(+), 4 deletions(-) 3 93 4 Add random kernel graph generator Generator of random graphs with a specified kernel. Includes a simple test and example to generate a G(n,p) graph using a kernel. The method is detailed in a (currently unpublished) paper. doc/source/reference/generators.rst;networkx/generators/random_graphs.py;networkx/generators/tests/test_random_graphs.py doc/source/reference/generators.rst | 1 +;networkx/generators/random_graphs.py | 87 +++++++++++++++++++++++--;networkx/generators/tests/test_random_graphs.py | 9 +++ +f454ebea21006d7d68d07dd0fefbe1cb0743e803 chebee7i chebee7i@gmail.com gmail Tue Aug 5 17:05:39 2014 -0500 2014-08-05 2014-08-05 22:05:39 stat 1 file changed, 4 insertions(+) 1 4 Test exceptions as well. networkx/generators/tests/test_random_graphs.py networkx/generators/tests/test_random_graphs.py | 4 ++++ +c0903b2d220ab2b4d03489a8550f160917a94e23 Jeffrey Finkelstein jeffrey.finkelstein@gmail.com gmail Tue Apr 12 15:05:25 2016 -0400 2016-04-12 2016-04-12 19:05:25 stat 3 files changed, 38 insertions(+), 7 deletions(-) 3 38 7 Abstracts many-to-one grouping function. This commit adds the utility function `groups()`, which, given a dictionary representing a many-to-one mapping, outputs the "inverse" one-to-many mapping, which maps values to the set of keys that have that value. networkx/algorithms/community/asyn_lpa.py;networkx/utils/misc.py;networkx/utils/tests/test_misc.py networkx/algorithms/community/asyn_lpa.py | 9 ++++-----;networkx/utils/misc.py | 28 ++++++++++++++++++++++++++--;networkx/utils/tests/test_misc.py | 8 ++++++++ +319009b9cca53c5244228bdccb679269428fa6d4 aric none@none None Sat Jul 31 13:57:04 2010 +0000 2010-07-31 2010-07-31 13:57:04 stat 1 file changed, 2 insertions(+) 1 2 Add isomorphism test files to manifest --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401809 MANIFEST.in MANIFEST.in | 2 ++ +816d22524c45f0d7d0b8e3c7821537559bb46c71 Aric Hagberg aric.hagberg@gmail.com gmail Sun Jan 20 08:08:57 2013 -0700 2013-01-20 2013-01-20 15:08:57 stat 3 files changed, 29 insertions(+), 30 deletions(-) 3 29 30 Set relabel mapping as node attributes. Use node attribute (specified as "label_attribute") in convert_node_labels_to_integers() instead of adding a mapping dict attribute to the Graph object. Addresses #820 networkx/readwrite/tests/test_edgelist.py;networkx/relabel.py;networkx/tests/test_relabel.py networkx/readwrite/tests/test_edgelist.py | 2 +-;networkx/relabel.py | 22 ++++++++-----------;networkx/tests/test_relabel.py | 35 +++++++++++++++++-------------- +410cba6e7ae095b0ad0aeb13a0697adbf165552f JGab jean.gabriel.young@gmail.com gmail Thu Apr 16 11:04:36 2015 -0400 2015-04-16 2015-04-16 15:04:36 stat 2 files changed, 11 insertions(+), 1 deletion(-) 2 11 1 Scipy fixture, doc fixes, and changelog doc/source/reference/api_2.0.rst;networkx/linalg/modularitymatrix.py doc/source/reference/api_2.0.rst | 9 +++++++++;networkx/linalg/modularitymatrix.py | 3 ++- +e256f9e622ffbf89e3b3694dc6bc813b7461c509 aric none@none None Tue Jul 12 23:35:35 2005 +0000 2005-07-12 2005-07-12 23:35:35 stat 136 files changed, 41912 insertions(+) 136 41912 initial svn layout --HG-- extra : convert_revision : svn%3A3ed01bd8-26fb-0310-9e4c-ca1a4053419f/networkx/trunk%401 .cvsignore;Doc/.cvsignore;Doc/COPYING;Doc/Credits.txt;Doc/Drawing.txt;Doc/Examples.txt;Doc/GNU_LGPL;Doc/Legal.txt;Doc/Makefile;Doc/Menu.txt;Doc/Overview.txt;Doc/Quick_ref.txt;Doc/README_epydoc;Doc/Readme.txt;Doc/Tutorial.txt;Doc/data/as.png;Doc/data/basic-s.png;Doc/data/blue_restructured.css;Doc/data/default.css;Doc/data/nx_doc.css;Doc/data/pydot-quote.patch;Doc/data/tetrahedral-s.png;Doc/test.py;Examples/.cvsignore;Examples/atlas.py;Examples/davis_club.py;Examples/degree_sequence.py;Examples/degree_sequence_gnuplot.py;Examples/degree_sequence_matplotlib.py;Examples/draw.py;Examples/eigenvalues.py;Examples/erdos_renyi.py;Examples/karate_club.py;Examples/kevin_bacon.dat;Examples/kevin_bacon.py;Examples/krackhardt_centrality.py;Examples/lanl.edges;Examples/lanl.py;Examples/miles.dat;Examples/miles.py;Examples/properties.py;Examples/read_write.py;Examples/roget.dat;Examples/roget.py;Examples/words.dat;Examples/words.py;Examples/write_dotfile.py;MANIFEST.in;NX/.cvsignore;NX/__init__.py;NX/base.py;NX/centrality.py;NX/cliques.py;NX/cluster.py;NX/cores.py;NX/drawing/.cvsignore;NX/drawing/__init__.py;NX/drawing/layout.py;NX/drawing/nx_pydot.py;NX/drawing/nx_pylab.py;NX/drawing/nx_vtk.py;NX/generators/.cvsignore;NX/generators/__init__.py;NX/generators/atlas.py;NX/generators/classic.py;NX/generators/degree_seq.py;NX/generators/geometric.py;NX/generators/random_graphs.py;NX/generators/small.py;NX/hybrid.py;NX/io.py;NX/isomorph.py;NX/operators.py;NX/paths.py;NX/queues.py;NX/release.py;NX/search.py;NX/search_class.py;NX/spectrum.py;NX/tests/.cvsignore;NX/tests/Makefile;NX/tests/README;NX/tests/__init__.py;NX/tests/base_DiGraph.txt;NX/tests/base_Graph.txt;NX/tests/centrality.txt;NX/tests/cliques.txt;NX/tests/cluster.txt;NX/tests/cores.txt;NX/tests/data/base_PseudoGraph_G.png;NX/tests/data/base_PseudoGraph_K.png;NX/tests/data/cores_Batagelj_example.png;NX/tests/data/cores_H.png;NX/tests/data/nx_doctest.css;NX/tests/data/paths_G.png;NX/tests/data/xbase_XDiGraph_G.png;NX/tests/data/xbase_XDiGraph_Z.png;NX/tests/data/xbase_XDiGraph_Zm.png;NX/tests/data/xbase_XDiGraph_Zms.png;NX/tests/data/xbase_XDiGraph_Zs.png;NX/tests/generators_atlas.txt;NX/tests/generators_classic.txt;NX/tests/generators_degree_seq.txt;NX/tests/generators_geometric.txt;NX/tests/generators_random_graphs.txt;NX/tests/generators_small.txt;NX/tests/hybrid.txt;NX/tests/io.txt;NX/tests/isomorph.txt;NX/tests/layout.txt;NX/tests/nx_pydot.txt;NX/tests/nx_pylab.txt;NX/tests/operators.txt;NX/tests/paths.txt;NX/tests/queues.txt;NX/tests/search.txt;NX/tests/search_class.txt;NX/tests/spectrum.txt;NX/tests/test.py;NX/tests/test2.py;NX/tests/threshold.txt;NX/tests/utils.txt;NX/tests/xbase_DiGraph.txt;NX/tests/xbase_Graph.txt;NX/tests/xbase_PseudoGraph.txt;NX/threshold.py;NX/utils.py;NX/xbase.py;PKG-INFO;README;Tools/adjlist2edgelist.py;Tools/adjmat2edgelist.py;Tools/bipartiteadjmat2edgelist.py;Tools/edgelist2adjlist.py;setup.py;setupext.py .cvsignore | 6 +;Doc/.cvsignore | 2 +;Doc/COPYING | 16 +;Doc/Credits.txt | 21 +;Doc/Drawing.txt | 78 +;Doc/Examples.txt | 48 +;Doc/GNU_LGPL | 504 ++;Doc/Legal.txt | 56 +;Doc/Makefile | 78 +;Doc/Menu.txt | 29 +;Doc/Overview.txt | 174 +;Doc/Quick_ref.txt | 296 +;Doc/README_epydoc | 23 +;Doc/Readme.txt | 83 +;Doc/Tutorial.txt | 746 ++;Doc/data/as.png | Bin 0 -> 220521 bytes;Doc/data/basic-s.png | Bin 0 -> 23955 bytes;Doc/data/blue_restructured.css | 104 +;Doc/data/default.css | 101 +;Doc/data/nx_doc.css | 101 +;Doc/data/pydot-quote.patch | 19 +;Doc/data/tetrahedral-s.png | Bin 0 -> 30573 bytes;Doc/test.py | 49 +;Examples/.cvsignore | 4 +;Examples/atlas.py | 82 +;Examples/davis_club.py | 156 +;Examples/degree_sequence.py | 37 +;Examples/degree_sequence_gnuplot.py | 53 +;Examples/degree_sequence_matplotlib.py | 48 +;Examples/draw.py | 39 +;Examples/eigenvalues.py | 44 +;Examples/erdos_renyi.py | 30 +;Examples/karate_club.py | 79 +;Examples/kevin_bacon.dat | 50 +;Examples/kevin_bacon.py | 74 +;Examples/krackhardt_centrality.py | 33 +;Examples/lanl.edges | 1363 ++++;Examples/lanl.py | 62 +;Examples/miles.dat | 701 ++;Examples/miles.py | 104 +;Examples/properties.py | 53 +;Examples/read_write.py | 26 +;Examples/roget.dat | 1038 +++;Examples/roget.py | 83 +;Examples/words.dat | 5762 ++++++++++++++;Examples/words.py | 101 +;Examples/write_dotfile.py | 32 +;MANIFEST.in | 16 +;NX/.cvsignore | 4 +;NX/__init__.py | 101 +;NX/base.py | 1547 ++++;NX/centrality.py | 231 +;NX/cliques.py | 390 +;NX/cluster.py | 148 +;NX/cores.py | 68 +;NX/drawing/.cvsignore | 3 +;NX/drawing/__init__.py | 18 +;NX/drawing/layout.py | 274 +;NX/drawing/nx_pydot.py | 159 +;NX/drawing/nx_pylab.py | 466 ++;NX/drawing/nx_vtk.py | 134 +;NX/generators/.cvsignore | 3 +;NX/generators/__init__.py | 73 +;NX/generators/atlas.py | 12349 +++++++++++++++++++++++++++++;NX/generators/classic.py | 426 +;NX/generators/degree_seq.py | 290 +;NX/generators/geometric.py | 95 +;NX/generators/random_graphs.py | 490 ++;NX/generators/small.py | 387 +;NX/hybrid.py | 125 +;NX/io.py | 316 +;NX/isomorph.py | 113 +;NX/operators.py | 374 +;NX/paths.py | 358 +;NX/queues.py | 127 +;NX/release.py | 24 +;NX/search.py | 195 +;NX/search_class.py | 336 +;NX/spectrum.py | 90 +;NX/tests/.cvsignore | 3 +;NX/tests/Makefile | 28 +;NX/tests/README | 13 +;NX/tests/__init__.py | 0;NX/tests/base_DiGraph.txt | 722 ++;NX/tests/base_Graph.txt | 773 ++;NX/tests/centrality.txt | 63 +;NX/tests/cliques.txt | 83 +;NX/tests/cluster.txt | 90 +;NX/tests/cores.txt | 62 +;NX/tests/data/base_PseudoGraph_G.png | Bin 0 -> 2644 bytes;NX/tests/data/base_PseudoGraph_K.png | Bin 0 -> 1625 bytes;NX/tests/data/cores_Batagelj_example.png | Bin 0 -> 6961 bytes;NX/tests/data/cores_H.png | Bin 0 -> 2114 bytes;NX/tests/data/nx_doctest.css | 104 +;NX/tests/data/paths_G.png | Bin 0 -> 32652 bytes;NX/tests/data/xbase_XDiGraph_G.png | Bin 0 -> 2620 bytes;NX/tests/data/xbase_XDiGraph_Z.png | Bin 0 -> 5964 bytes;NX/tests/data/xbase_XDiGraph_Zm.png | Bin 0 -> 9024 bytes;NX/tests/data/xbase_XDiGraph_Zms.png | Bin 0 -> 11096 bytes;NX/tests/data/xbase_XDiGraph_Zs.png | Bin 0 -> 7823 bytes;NX/tests/generators_atlas.txt | 12 +;NX/tests/generators_classic.txt | 614 ++;NX/tests/generators_degree_seq.txt | 114 +;NX/tests/generators_geometric.txt | 7 +;NX/tests/generators_random_graphs.txt | 27 +;NX/tests/generators_small.txt | 292 +;NX/tests/hybrid.txt | 32 +;NX/tests/io.txt | 62 +;NX/tests/isomorph.txt | 28 +;NX/tests/layout.txt | 13 +;NX/tests/nx_pydot.txt | 93 +;NX/tests/nx_pylab.txt | 38 +;NX/tests/operators.txt | 335 +;NX/tests/paths.txt | 146 +;NX/tests/queues.txt | 17 +;NX/tests/search.txt | 54 +;NX/tests/search_class.txt | 43 +;NX/tests/spectrum.txt | 56 +;NX/tests/test.py | 80 +;NX/tests/test2.py | 46 +;NX/tests/threshold.txt | 148 +;NX/tests/utils.txt | 55 +;NX/tests/xbase_DiGraph.txt | 836 ++;NX/tests/xbase_Graph.txt | 668 ++;NX/tests/xbase_PseudoGraph.txt | 731 ++;NX/threshold.py | 652 ++;NX/utils.py | 302 +;NX/xbase.py | 1855 +++++;PKG-INFO | 16 +;README | 13 +;Tools/adjlist2edgelist.py | 15 +;Tools/adjmat2edgelist.py | 18 +;Tools/bipartiteadjmat2edgelist.py | 19 +;Tools/edgelist2adjlist.py | 25 +;setup.py | 111 +;setupext.py | 80 + diff --git a/gitnet/gitnet_tests/test_helpers.py b/gitnet/gitnet_tests/test_helpers.py index 8590194..e550898 100644 --- a/gitnet/gitnet_tests/test_helpers.py +++ b/gitnet/gitnet_tests/test_helpers.py @@ -341,34 +341,36 @@ class TestAnnotateHelpers(unittest.TestCase): def test_make_utc_date(self): """Is the function converting the string properly?""" utc = helpers.make_utc_date({"date":"Mon Jul 22 11:40:03 2013 -0600"}) - self.assertEquals(utc, "2013-07-22") + self.assertEqual(utc, "2013-07-22") utc = helpers.make_utc_date({"date":"Sat Apr 16 22:29:50 2016 -0200"}) - self.assertEquals(utc, "2016-04-17") + self.assertEqual(utc, "2016-04-17") utc = helpers.make_utc_date({"date":"Fri Oct 5 12:20:15 2012 +0200"}) - self.assertEquals(utc, "2012-10-05") + self.assertEqual(utc, "2012-10-05") utc = helpers.make_utc_date({"not":"Fri Oct 5 12:20:15 2012 +0200"}) - self.assertEquals(utc, None) + self.assertEqual(utc, None) def test_make_utc_datetime(self): """Is the function converting the string properly?""" utc = helpers.make_utc_datetime({"date":"Mon Jul 22 11:40:03 2013 -0600"}) - self.assertEquals(utc, "2013-07-22 17:40:03") + self.assertEqual(utc, "2013-07-22 17:40:03") utc = helpers.make_utc_datetime({"date":"Sat Apr 16 22:29:50 2016 -0200"}) - self.assertEquals(utc, "2016-04-17 00:29:50") + self.assertEqual(utc, "2016-04-17 00:29:50") utc = helpers.make_utc_datetime({"date":"Fri Oct 5 12:20:15 2012 +0200"}) - self.assertEquals(utc, "2012-10-05 10:20:15") + self.assertEqual(utc, "2012-10-05 10:20:15") utc = helpers.make_utc_datetime({"not":"Fri Oct 5 12:20:15 2012 +0200"}) - self.assertEquals(utc, None) + self.assertEqual(utc, None) def test_make_domain(self): - self.assertEquals(helpers.make_domain({"email":"mail@hoolagin.com"}), "hoolagin") - self.assertEquals(helpers.make_domain({"email":"joe@gmail.com"}), "gmail") - self.assertEquals(helpers.make_domain({"email":"afsjkl@gar.net"}), "gar") - self.assertEquals(helpers.make_domain({"email":"linux@cs.uwaterloo.ca"}), "cs.uwaterloo") - self.assertEquals(helpers.make_domain({"notemail":"mail@hoolagin.com"}), None) - self.assertEquals(helpers.make_domain({"email":"mailhoolagin.com"}), None) - self.assertEquals(helpers.make_domain({"email":"mail@hoolagincom"}), None) - self.assertEquals(helpers.make_domain({"email":"mail@.com"}), None) + self.assertEqual(helpers.make_domain({"email":"mail@hoolagin.com"}), "hoolagin") + self.assertEqual(helpers.make_domain({"email":"joe@gmail.com"}), "gmail") + self.assertEqual(helpers.make_domain({"email":"afsjkl@gar.net"}), "gar") + self.assertEqual(helpers.make_domain({"email":"linux@cs.uwaterloo.ca"}), "cs.uwaterloo") + self.assertEqual(helpers.make_domain({"notemail":"mail@hoolagin.com"}), None) + self.assertEqual(helpers.make_domain({"email":"mailhoolagin.com"}), None) + self.assertEqual(helpers.make_domain({"email":"mail@hoolagincom"}), None) + self.assertEqual(helpers.make_domain({"email":"mail@.com"}), None) + self.assertEqual(helpers.make_domain({"email":""}), None) + self.assertEqual(helpers.make_domain({"email":None}), None) if __name__ == '__main__': unittest.main(buffer=True) diff --git a/gitnet/helpers.py b/gitnet/helpers.py index 06d85be..679ac10 100644 --- a/gitnet/helpers.py +++ b/gitnet/helpers.py @@ -14,8 +14,9 @@ # If not, see . # ********************************************************************************************* -import datetime as dt import re +import warnings +import datetime as dt from gitnet.exceptions import InputError # Working with Git Log date strings @@ -471,18 +472,24 @@ def make_domain(dict): """ # Check if email is in the data dictionary. if "email" in dict: - # Handling invalid emails. Check if the string is valid format with regex. - email_re = re.compile(".+@.+\..+") - if not re.match(email_re,dict["email"]): + try: + # Handling invalid emails. Check if the string is valid format with regex. + if dict["email"] == "" or dict["email"] == None: + return None + email_re = re.compile(".+@.+\..+") + if not re.match(email_re,dict["email"]): + return None + # Handling valid emails by stripping away non-domain characters. + domain = dict["email"].split("@")[1] + go = True + while go: + if domain[-1] == ".": + go = False + domain = domain[:-1] + return domain + except: return None - # Handling valid emails by stripping away non-domain characters. - domain = dict["email"].split("@")[1] - go = True - while go: - if domain[-1] == ".": - go = False - domain = domain[:-1] - return domain + warnings.warn("Domain generator failed for: [{}]. Assigned None value.".format(dict["email"])) # If missing, produce none. else: return None \ No newline at end of file From c0d107f1921e523e3391619914166642adcd7e8a Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Fri, 14 Oct 2016 10:31:49 -0400 Subject: [PATCH 08/14] Updated generate_network documentation. --- gitnet/log.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitnet/log.py b/gitnet/log.py index 9bc2ee6..175670c 100644 --- a/gitnet/log.py +++ b/gitnet/log.py @@ -733,11 +733,11 @@ def generate_network(self, mode1, mode2, colours=None, edge_helper=net_edges_sim Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). From 1fbe914935fee3273430da60d870b58f25f603be Mon Sep 17 00:00:00 2001 From: Joel Becker Date: Fri, 17 Feb 2017 16:28:07 -0500 Subject: [PATCH 09/14] 1. Small changes to default behaviour for edge generation. 2. Updated the docs. --- docs/gitnet/commit_log.m.html | 263 +- docs/gitnet/exceptions.m.html | 7 +- docs/gitnet/get_log.m.html | 109 +- .../gitnet_tests/test_commit_log.m.html | 3204 ++++++- docs/gitnet/gitnet_tests/test_get.m.html | 492 +- docs/gitnet/gitnet_tests/test_helpers.m.html | 3509 +++++-- docs/gitnet/gitnet_tests/test_log.m.html | 8227 ++++++++++------- docs/gitnet/gitnet_tests/test_netgen.m.html | 586 +- docs/gitnet/gitnet_tests/test_network.m.html | 980 +- docs/gitnet/helpers.m.html | 296 +- docs/gitnet/log.m.html | 1177 ++- docs/gitnet/multigraph.m.html | 1582 ++-- gitnet/log.py | 10 +- 13 files changed, 13334 insertions(+), 7108 deletions(-) diff --git a/docs/gitnet/commit_log.m.html b/docs/gitnet/commit_log.m.html index dc0a59c..9a1776a 100644 --- a/docs/gitnet/commit_log.m.html +++ b/docs/gitnet/commit_log.m.html @@ -1048,6 +1048,8 @@
  • __init__
  • +
  • add_attribute
  • +
  • annotate
  • attributes
  • author_email_list
  • browse
  • @@ -1060,6 +1062,7 @@
  • generate_nodes
  • get_tags
  • ignore
  • +
  • mutate_attribute
  • network
  • replace_val
  • tsv
  • @@ -1108,7 +1111,8 @@

    gitnet.commit_log module

    import copy from gitnet.log import Log from gitnet.exceptions import InputError -from gitnet.helpers import datetime_git, most_common, filter_regex, net_edges_simple, net_edges_changes +from gitnet.helpers import datetime_git, most_common, filter_regex, net_edges_simple, net_edges_changes, \ + make_utc_datetime, make_utc_date, make_domain class CommitLog(Log): @@ -1116,6 +1120,17 @@

    gitnet.commit_log module

    A subclass of `Log` for holding git commit logs, whose data has been parsed into a dictionary of dictionaries. """ + def annotate(self): + """ + A method that automatically runs after initialization. Processes date information, and adds easily parsed + date strings to each record. + utc_date : "YYYY-MM-DD" in Coordinated Universal Time. Formatted for `parse_date()` in `readr` package in R. + utc_datetime : "YYYY-MM-DD HH:MM:SS" in Coordinated Universal Time. + """ + self.mutate_attribute("utc_date",make_utc_date) + self.mutate_attribute("utc_datetime",make_utc_datetime) + self.mutate_attribute("domain",make_domain) + def describe(self, mode = "default", exclude = []): """ A method for creating extended descriptive output for the `Commitlog` subclass. @@ -1152,10 +1167,10 @@

    gitnet.commit_log module

    # Define included/excluded data summaries. if mode == "default": output = ["summary", "path", "filters", "authors", "files", - "emails", "dates", "changes", "merges", "errors"] + "emails", "domain", "date", "utc_date", "utc_datetime", "changes", "merges", "errors"] else: output = ["summary", "path", "filters", "authors", "files", - "emails", "dates", "changes", "merges", "errors"] + "emails", "domain", "date", "utc_date", "utc_datetime", "changes", "merges", "errors"] for i in exclude: output.remove(i) # Print summary @@ -1265,7 +1280,7 @@

    gitnet.commit_log module

    > A list of ordered reference hashes. """ - return ["hash","author","email","date","mode","merge","summary", + return ["hash","author","email","domain","date","utc_date","utc_datetime","mode","merge","summary", "fedits","inserts","deletes","message","files","changes"] def ignore(self, pattern, ignoreif="match"): @@ -1306,7 +1321,7 @@

    gitnet.commit_log module

    ignore_note = "matches" elif ignoreif == "no match": ignore_note = "doesn't match" - summary = "Ignore files that {} the regular expression: {}".format(ignore_note,pattern) + summary = "Ignore files that {} the regular expression: {}".format(ignore_note, pattern) self_copy.filters.append(summary) return self_copy @@ -1368,6 +1383,17 @@

    Classes

    A subclass of `Log` for holding git commit logs, whose data has been parsed into a dictionary of dictionaries. """ + def annotate(self): + """ + A method that automatically runs after initialization. Processes date information, and adds easily parsed + date strings to each record. + utc_date : "YYYY-MM-DD" in Coordinated Universal Time. Formatted for `parse_date()` in `readr` package in R. + utc_datetime : "YYYY-MM-DD HH:MM:SS" in Coordinated Universal Time. + """ + self.mutate_attribute("utc_date",make_utc_date) + self.mutate_attribute("utc_datetime",make_utc_datetime) + self.mutate_attribute("domain",make_domain) + def describe(self, mode = "default", exclude = []): """ A method for creating extended descriptive output for the `Commitlog` subclass. @@ -1404,10 +1430,10 @@

    Classes

    # Define included/excluded data summaries. if mode == "default": output = ["summary", "path", "filters", "authors", "files", - "emails", "dates", "changes", "merges", "errors"] + "emails", "domain", "date", "utc_date", "utc_datetime", "changes", "merges", "errors"] else: output = ["summary", "path", "filters", "authors", "files", - "emails", "dates", "changes", "merges", "errors"] + "emails", "domain", "date", "utc_date", "utc_datetime", "changes", "merges", "errors"] for i in exclude: output.remove(i) # Print summary @@ -1517,7 +1543,7 @@

    Classes

    > A list of ordered reference hashes. """ - return ["hash","author","email","date","mode","merge","summary", + return ["hash","author","email","domain","date","utc_date","utc_datetime","mode","merge","summary", "fedits","inserts","deletes","message","files","changes"] def ignore(self, pattern, ignoreif="match"): @@ -1558,7 +1584,7 @@

    Classes

    ignore_note = "matches" elif ignoreif == "no match": ignore_note = "doesn't match" - summary = "Ignore files that {} the regular expression: {}".format(ignore_note,pattern) + summary = "Ignore files that {} the regular expression: {}".format(ignore_note, pattern) self_copy.filters.append(summary) return self_copy @@ -1679,7 +1705,8 @@

    Static methods

    self.path = path self.key_type = key_type self.filters = filters - # This must be updated as tags/subclasses are added. Ideally, this would be housed within each subclass. + # Annotate and tags must be updated as tags/subclasses are added. + self.annotate() self.tags = self.get_tags() @@ -1689,6 +1716,89 @@

    Static methods

    +
    +
    +

    def add_attribute(

    self, name, helper)

    +
    + + + + +

    Creates a new record attribute.

    +

    Parameters :

    +
    +

    name : string

    +
    +

    The name of the new attribute.

    +
    +

    helper : None

    +
    +

    A helper function, which takes an attribute dict and produces the new attribute.

    +
    +
    +

    Return :

    +
    +

    A new Log object, identical to self but with the desired attribute.

    +
    +
    + +
    +
    def add_attribute(self,name,helper):
    +    """
    +    Creates a new record attribute.
    +    **Parameters** :
    +    > *name* : `string`
    +    >> The name of the new attribute.
    +    > *helper* : `None`
    +    >> A helper function, which takes an attribute dict and produces the new attribute.
    +    **Return** :
    +    > A new Log object, identical to self but with the desired attribute.
    +    """
    +    self_copy = copy.deepcopy(self)
    +    for n in self_copy:
    +        self_copy[n][name] = helper(self_copy[n])
    +    return self_copy
    +
    + +
    +
    + +
    + + +
    +
    +

    def annotate(

    self)

    +
    + + + + +

    A method that automatically runs after initialization. Processes date information, and adds easily parsed +date strings to each record. +utc_date : "YYYY-MM-DD" in Coordinated Universal Time. Formatted for parse_date() in readr package in R. +utc_datetime : "YYYY-MM-DD HH:MM:SS" in Coordinated Universal Time.

    +
    + +
    +
    def annotate(self):
    +    """
    +    A method that automatically runs after initialization. Processes date information, and adds easily parsed
    +    date strings to each record.
    +    utc_date : "YYYY-MM-DD" in Coordinated Universal Time. Formatted for `parse_date()` in `readr` package in R.
    +    utc_datetime : "YYYY-MM-DD HH:MM:SS" in Coordinated Universal Time.
    +    """
    +    self.mutate_attribute("utc_date",make_utc_date)
    +    self.mutate_attribute("utc_datetime",make_utc_datetime)
    +    self.mutate_attribute("domain",make_domain)
    +
    + +
    +
    + +
    + +

    def attributes(

    self)

    @@ -1879,10 +1989,10 @@

    Static methods

    # Define included/excluded data summaries. if mode == "default": output = ["summary", "path", "filters", "authors", "files", - "emails", "dates", "changes", "merges", "errors"] + "emails", "domain", "date", "utc_date", "utc_datetime", "changes", "merges", "errors"] else: output = ["summary", "path", "filters", "authors", "files", - "emails", "dates", "changes", "merges", "errors"] + "emails", "domain", "date", "utc_date", "utc_datetime", "changes", "merges", "errors"] for i in exclude: output.remove(i) # Print summary @@ -2274,7 +2384,7 @@

    Static methods

    -

    def generate_edges(

    self, mode1, mode2, helper=<function net_edges_simple at 0x112d7a6a8>, edge_attributes=[])

    +

    def generate_edges(

    self, mode1, mode2, helper=<function net_edges_simple at 0x10fdd0a60>, edge_attributes=[])

    @@ -2361,7 +2471,7 @@

    Static methods

    -

    def generate_network(

    self, mode1, mode2, edge_helper=<function net_edges_simple at 0x112d7a6a8>, edge_attributes=[], mode1_atom_attrs=[], mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[])

    +

    def generate_network(

    self, mode1, mode2, colours=None, edge_helper=<function net_edges_simple at 0x10fdd0a60>, edge_attributes=[], mode1_atom_attrs=[], mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[])

    @@ -2379,6 +2489,14 @@

    Static methods

    The tag string for the second mode type.

    +

    colours : string

    +
    +

    The string that specifies the colour preset desired by the user. +Simple : Returns a graph in which each mode is a different colour (red and white). Attention to the order of modes is required, as there is no table. +Complex : Returns a graph in which each mode is a different colour, and if files is one of the modes, popular file types will be a different colour. +Otherwise, simply do not include the colour argument. The defualt colour is light grey for all nodes. +Enabling colours will also add the colours column to the node data, which will allow importing into other software. See the walkthrough and R tutorial for the example.

    +

    edge_helper : None

    The helper function used to compute an edge.

    @@ -2411,11 +2529,11 @@

    Static methods

    Notes :

    Currently, two edge_helper functions are available in gitnet.gn_helpers:

    -

    simple_edge

    +

    net_edges_simple

    Creates an unweighted edge, and saves the attributes specified by edge_attributes.

    -

    changes_edge

    +

    net_edges_changes

    Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog).

    Computes edges between authors and files based on the number of lines changed in the

    @@ -2425,7 +2543,7 @@

    Static methods

    -
    def generate_network(self, mode1, mode2, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[],
    +    
    def generate_network(self, mode1, mode2, colours=None, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[],
                          mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[]):
         """
         An abstract network generator. For networks that contain authors, any authors that made
    @@ -2435,6 +2553,12 @@ 

    Static methods

    >> The tag string for the first mode type. > *mode2* : `string` >> The tag string for the second mode type. + > *colours* : `string` + >> The string that specifies the colour preset desired by the user. + >> *Simple* : Returns a graph in which each mode is a different colour (red and white). Attention to the order of modes is required, as there is no table. + >> *Complex* : Returns a graph in which each mode is a different colour, and if `files` is one of the modes, popular file types will be a different colour. + >> Otherwise, simply do not include the colour argument. The defualt colour is light grey for all nodes. + >> Enabling colours will also add the colours column to the node data, which will allow importing into other software. See the walkthrough and R tutorial for the example. > *edge_helper* : `None` >> The helper function used to compute an edge. > *edge_attributes* : `list` @@ -2451,9 +2575,9 @@

    Static methods

    > A `MultiGraphPlus` object, which inherits from the NetworkX MultiGraph class. **Notes** : Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). >> Computes edges between authors and files based on the number of lines changed in the >> corresponding changes string (for example, the weight is 6 for `README.md | 6 +++---`). @@ -2470,6 +2594,30 @@

    Static methods

    edges = self.generate_edges(mode1, mode2, helper=edge_helper, edge_attributes=edge_attributes) for edge in edges: graph.add_edges_from([(edge[0], edge[1], edge[2])]) + if colours != None: + if colours == 'simple': + for n in graph.nodes(): + if graph.node[n]['type'] == mode1: + graph.node[n]['colour'] = 'oldlace' + if graph.node[n]['type'] == mode2: + graph.node[n]['colour'] = 'lightcoral' + elif colours == 'complex': + for n in graph.nodes(): + if graph.node[n]['type'] == 'author': + graph.node[n]['colour'] = 'oldlace' + elif ".py" in graph.node[n]['id']: + graph.node[n]['colour'] = 'springgreen' + elif ".cc" in graph.node[n]['id']: + graph.node[n]['colour'] = 'seagreen' + elif ".md" in graph.node[n]['id']: + graph.node[n]['colour'] = 'orange' + elif ".sh" in graph.node[n]['id']: + graph.node[n]["colour"] = "slateblue" + elif ".html" in graph.node[n]["id"]: + graph.node[n]["colour"] = "plum" + else: + graph.node[n]['colour'] = 'lightgrey' + print('Created a MultiGraphPlus network object with {} nodes and {} edges.'.format(graph.number_of_nodes(), graph.number_of_edges())) return graph
    @@ -2644,7 +2792,7 @@

    Static methods

    **Return** `list` > A list of ordered reference hashes. """ - return ["hash","author","email","date","mode","merge","summary", + return ["hash","author","email","domain","date","utc_date","utc_datetime","mode","merge","summary", "fedits","inserts","deletes","message","files","changes"]
    @@ -2712,7 +2860,7 @@

    Static methods

    ignore_note = "matches" elif ignoreif == "no match": ignore_note = "doesn't match" - summary = "Ignore files that {} the regular expression: {}".format(ignore_note,pattern) + summary = "Ignore files that {} the regular expression: {}".format(ignore_note, pattern) self_copy.filters.append(summary) return self_copy
    @@ -2723,6 +2871,54 @@

    Static methods

    +
    +
    +

    def mutate_attribute(

    self, name, helper)

    +
    + + + + +

    Creates a new record attribute, mutating the original log.

    +

    Parameters :

    +
    +

    name : string

    +
    +

    The name of the new attribute.

    +
    +

    helper : None

    +
    +

    A helper function, which takes an attribute dict and produces the new attribute.

    +
    +
    +

    Return :

    +
    +

    None

    +
    +
    + +
    +
    def mutate_attribute(self,name,helper):
    +    """
    +    Creates a new record attribute, mutating the original log.
    +    **Parameters** :
    +    > *name* : `string`
    +    >> The name of the new attribute.
    +    > *helper* : `None`
    +    >> A helper function, which takes an attribute dict and produces the new attribute.
    +    **Return** :
    +    > None
    +    """
    +    for n in self:
    +        self[n][name] = helper(self[n])
    +
    + +
    +
    + +
    + +

    def network(

    self, type)

    @@ -2840,9 +3036,9 @@

    Static methods

    elif cur_val != selfcopy.collection[record][tag] and replaced_vals == 0: status = 1 if status == 0: - warnings.warn("The tag requested does not appear in this collection.") + warnings.warn("Failed. The tag requested does not appear in this collection.") elif status == 1: - warnings.warn("The value requested does not appear in any records in this collection.") + warnings.warn("Failed. The value requested does not appear in any records in this collection.") elif status == 2: print("Success. You have replaced the " + tag + " value: " + str(cur_val) + " " + str(replaced_vals) + " times.") return selfcopy @@ -2856,7 +3052,7 @@

    Static methods

    -

    def tsv(

    self, ignore=[], fname=None, empty_cols=False)

    +

    def tsv(

    self, fname, ignore=[], empty_cols=False)

    @@ -2887,7 +3083,7 @@

    Static methods

    -
    def tsv(self, ignore=[], fname=None, empty_cols=False):
    +    
    def tsv(self, fname, ignore=[], empty_cols=False):
         """
         Converts the `Log` to a tab-delimited string (using a tab-delimted format is preferrable to CSV since this option
         does not change the content strings by removing commas).
    @@ -2973,7 +3169,8 @@ 

    Static methods

    warnings.warn("Non-string input forced to string {} time(s).".format(num_forced)) if fname is not None: f.close() - out = "Data written to {}".format(fname) + out = "Data written to {} in {}".format(fname, os.getcwd()) + print(out) return out
    @@ -3035,7 +3232,7 @@

    Static methods

    -

    def write_edges(

    self, fname, mode1, mode2, helper=<function net_edges_simple at 0x112d7a6a8>, edge_attribute=['weight', 'date'])

    +

    def write_edges(

    self, fname, mode1, mode2, helper=<function net_edges_simple at 0x10fdd0a60>, edge_attribute=['weight', 'date'])

    @@ -3069,11 +3266,11 @@

    Static methods

    Notes :

    Currently, two edge_helper functions are available in gitnet.gn_helpers:

    -

    simple_edge

    +

    net_edges_simple

    Creates an unweighted edge, and saves the attributes specified by edge_attributes.

    -

    changes_edge

    +

    net_edges_changes

    Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog).

    Computes edges between authors and files based on the number of lines changed in the

    @@ -3100,9 +3297,9 @@

    Static methods

    **Return** : `None` **Notes** : Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). >> Computes edges between authors and files based on the number of lines changed in the >> corresponding changes string (for example, the weight is 6 for `README.md | 6 +++---`). @@ -3134,7 +3331,7 @@

    Static methods

    f.write("\n") # Close file and print summary. f.close() - print("Wrote edgelist with attributes to {}.".format(fname)) + print("Wrote edgelist with attributes to {} in {}.".format(fname, os.getcwd()))
    @@ -3245,7 +3442,7 @@

    Static methods

    else: f.write("\n") f.close() - print("Wrote node attributes to {}.".format(fname)) + print("Wrote node attributes to {} in {}.".format(fname, os.getcwd()))
    diff --git a/docs/gitnet/exceptions.m.html b/docs/gitnet/exceptions.m.html index 0d87c3d..c1708e0 100644 --- a/docs/gitnet/exceptions.m.html +++ b/docs/gitnet/exceptions.m.html @@ -1154,7 +1154,7 @@

    gitnet.exceptions module

    class GraphStatsError(gitnetException): """ - Exception given when the statistics are not generated as expected. + Exception given when the network graph statistics are not generated as expected. """ pass
    @@ -1217,13 +1217,13 @@

    Class variables

    class GraphStatsError

    -

    Exception given when the statistics are not generated as expected.

    +

    Exception given when the network graph statistics are not generated as expected.

    class GraphStatsError(gitnetException):
         """
    -    Exception given when the statistics are not generated as expected.
    +    Exception given when the network graph statistics are not generated as expected.
         """
         pass
     
    @@ -1492,7 +1492,6 @@

    Class variables

    class gitnetException

    -

    Common base class for all non-exit exceptions.

    diff --git a/docs/gitnet/get_log.m.html b/docs/gitnet/get_log.m.html index a0c12ca..427e375 100644 --- a/docs/gitnet/get_log.m.html +++ b/docs/gitnet/get_log.m.html @@ -1084,56 +1084,41 @@

    gitnet.get_log module

    # ********************************************************************************************* import bash as sh +import subprocess as sub import os import warnings from gitnet.exceptions import RepositoryError, ParseError, InputError from gitnet.commit_log import CommitLog - -def retrieve_commits(path, mode = "stat"): +def get_log(path, mode="stat", commit_source="local git"): """ - Takes a file path string and a mode string and produces the git log for the - specified directory. The default mode, "stat" retrieves the logs by running "git log --stat". - Modes include: "basic" (git log), "raw" ("git log --raw"), and "stat" ("git log --stat"). + A function for gathering data from a local Git repository. **Parameters** : > *path* : `string` - >> A string identifying the path to the target git repository. + >> A string containing the path of the Git repository. > *mode* : `string` - >> A string identifying the git log mode to be retrieved. Default mode is "stat". + >> The retrieval mode. Modes currently implemented: "basic", "raw", "stat". - **Return** : + > *commit_source* : `string` - > Returns a large string containing the raw output from the repository's git log. + >> The source of the Git repository, local is currently the only option. - """ - print("Attempting local git log retrieval...") - # Log command modes, referenced by "mode" input. - log_commands = {"basic": "git log", "raw": "git log --raw", "stat":"git log --stat"} - if mode not in log_commands.keys(): - raise InputError("{} is not a valid retrieval mode.".format(mode)) - # Save the current directory. Navigate to new directory. Retrieve logs. Return to original directory. - work_dir = os.getcwd() - os.chdir(path) - raw_logs = sh.bash(log_commands[mode]).stdout.decode("utf-8") - os.chdir(work_dir) - # If the retrieval was unsuccessful, raise an error. - if len(raw_logs) == 0: - print("Raising error.") - if "true" in str(sh.bash("git rev-parse --is-inside-work-tree").stdout): - raise RepositoryError("{} is not a Git repository.".format(path)) - else: - raise RepositoryError("{} has no commits.".format(path)) - # If the retrieval was successful, print a summary." - print("Got {} characters from: {}".format(len(raw_logs), path)) - # Record the retrieval mode. - raw_logs = "Mode =\n{}\n".format(mode) + raw_logs - return raw_logs + **Returns** : `Commitlog` + """ + if commit_source == "local git": + detect_key = "hash" + else: + detect_key = "unknown" + return CommitLog(dofd=parse_commits(retrieve_commits(path, mode)), + source=commit_source, + path=path, + key_type=detect_key) def identify(s): """ @@ -1185,7 +1170,6 @@

    gitnet.get_log module

    " so was identified as 'other'.".format(s)) return "none" - def parse_commits(commit_str): """ Parses a raw string containing a commit Log for a Git repository. It produces a dictionary @@ -1282,36 +1266,49 @@

    gitnet.get_log module

    warnings.warn("Parser was unable to identify {}. Identity string <{}> not recognized".format(line,id)) return collection - -def get_log(path, mode="stat", commit_source="local git"): +def retrieve_commits(path, mode="stat"): """ - A function for gathering data from a local Git repository. + Takes a file path string and a mode string and produces the git log for the + specified directory. The default mode, "stat" retrieves the logs by running "git log --stat". + Modes include: "basic" (git log), "raw" ("git log --raw"), and "stat" ("git log --stat"). **Parameters** : > *path* : `string` - >> A string containing the path of the Git repository. + >> A string identifying the path to the target git repository. > *mode* : `string` - >> The retrieval mode. Modes currently implemented: "basic", "raw", "stat". - - > *commit_source* : `string` + >> A string identifying the git log mode to be retrieved. Default mode is "stat". - >> The source of the Git repository, local is currently the only option. + **Return** : - **Returns** : `Commitlog` + > Returns a large string containing the raw output from the repository's git log. """ - if commit_source == "local git": - detect_key = "hash" - else: - detect_key = "unknown" - return CommitLog(dofd = parse_commits(retrieve_commits(path,mode)), - source = commit_source, - path = path, - key_type = detect_key) + print("Attempting local git log retrieval...") + # Log command modes, referenced by "mode" input. + log_commands = {"basic": "git log", "raw": "git log --raw", "stat":"git log --stat"} + if mode not in log_commands.keys(): + raise InputError("{} is not a valid retrieval mode.".format(mode)) + # Save the current directory. Navigate to new directory. Retrieve logs. Return to original directory. + work_dir = os.getcwd() + os.chdir(path) + raw_logs = sh.bash(log_commands[mode]).stdout.decode("utf-8", "ignore") + os.chdir(work_dir) + # If the retrieval was unsuccessful, raise an error. + if len(raw_logs) == 0: + print("Raising error.") + if "true" in str(sh.bash("git rev-parse --is-inside-work-tree").stdout): + raise RepositoryError("{} is not a Git repository.".format(path)) + else: + raise RepositoryError("{} has no commits.".format(path)) + # If the retrieval was successful, print a summary." + print("Got {} characters from: {}".format(len(raw_logs), path)) + # Record the retrieval mode. + raw_logs = "Mode =\n{}\n".format(mode) + raw_logs + return raw_logs
    @@ -1375,10 +1372,10 @@

    Functions

    detect_key = "hash" else: detect_key = "unknown" - return CommitLog(dofd = parse_commits(retrieve_commits(path,mode)), - source = commit_source, - path = path, - key_type = detect_key) + return CommitLog(dofd=parse_commits(retrieve_commits(path, mode)), + source=commit_source, + path=path, + key_type=detect_key)
    @@ -1644,7 +1641,7 @@

    Functions

    -
    def retrieve_commits(path, mode = "stat"):
    +    
    def retrieve_commits(path, mode="stat"):
         """
         Takes a file path string and a mode string and produces the  git log for the
         specified directory. The default mode, "stat" retrieves the logs by running "git log --stat".
    @@ -1673,7 +1670,7 @@ 

    Functions

    # Save the current directory. Navigate to new directory. Retrieve logs. Return to original directory. work_dir = os.getcwd() os.chdir(path) - raw_logs = sh.bash(log_commands[mode]).stdout.decode("utf-8") + raw_logs = sh.bash(log_commands[mode]).stdout.decode("utf-8", "ignore") os.chdir(work_dir) # If the retrieval was unsuccessful, raise an error. if len(raw_logs) == 0: diff --git a/docs/gitnet/gitnet_tests/test_commit_log.m.html b/docs/gitnet/gitnet_tests/test_commit_log.m.html index f805fc3..34df2fd 100644 --- a/docs/gitnet/gitnet_tests/test_commit_log.m.html +++ b/docs/gitnet/gitnet_tests/test_commit_log.m.html @@ -1040,6 +1040,81 @@

    Index

  • Classes

      +
    • + AnnotateTests + + + + +
    • DescribeTests @@ -1076,7 +1151,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1156,7 +1230,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1230,7 +1303,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1306,7 +1378,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1402,12 +1473,43 @@

      gitnet.gitnet_tests.test_commit_log tags = my_log.get_tags() - self.assertListEqual(tags, ["hash", "author", "email", "date", "mode", "merge", "summary", - "fedits", "inserts", "deletes", "message", "files", "changes"]) + self.assertListEqual(tags, ["hash", "author", "email", "domain", "date", "utc_date", "utc_datetime", "mode", "merge", + "summary", "fedits", "inserts", "deletes", "message", "files", "changes"]) # Delete temporary .git file sub.call(["rm", "-rf", ".git"]) +class AnnotateTests(unittest.TestCase): + def setUp(self): + # Set up small network + sub.call(["cp", "-R", "small_network_repo.git", ".git"]) + path = os.getcwd() + self.my_log = gitnet.get_log(path) + + def test_utc_date(self): + """Is utc_date being generated correctly?""" + self.assertEqual(self.my_log["7965e62"]["utc_date"],"2016-05-26") + self.assertEqual(self.my_log["6cd4bbf"]["utc_date"],"2016-05-25") + self.assertEqual(self.my_log["ee2c408"]["utc_date"],"2016-05-23") + self.assertEqual(self.my_log["b3a4bac"]["utc_date"],"2016-05-20") + + def test_utc_datetime(self): + """Is utc_datetime being generated correctly?""" + self.assertEqual(self.my_log["7965e62"]["utc_datetime"],"2016-05-26 15:21:03") + self.assertEqual(self.my_log["6cd4bbf"]["utc_datetime"],"2016-05-25 05:12:48") + self.assertEqual(self.my_log["ee2c408"]["utc_datetime"],"2016-05-23 06:45:25") + self.assertEqual(self.my_log["b3a4bac"]["utc_datetime"],"2016-05-20 13:19:20") + + def test_domain(self): + """Is domain being generated correctly?""" + self.assertEqual(self.my_log["7965e62"]["domain"],"gmail") + self.assertEqual(self.my_log["6cd4bbf"]["domain"],"gmail") + self.assertEqual(self.my_log["ee2c408"]["domain"],"gmail") + self.assertEqual(self.my_log["b3a4bac"]["domain"],"gmail") + + def tearDown(self): + # Delete temporary .git file + sub.call(["rm", "-rf", ".git"]) class DescribeTests(unittest.TestCase): def setUp(self): @@ -1695,121 +1797,2430 @@

      gitnet.gitnet_tests.test_commit_log self.assertNotIn('weight', aut_file.node[a]) self.assertNotIn('date', aut_file.node[a]) - file_list = ['file1.md', 'file2.md', 'file3.md', 'file4.md', 'file5.md', 'file6.md', 'file7.md'] - for f in file_list: - self.assertIn('id', aut_file.node[f]) - self.assertIn('type', aut_file.node[f]) - self.assertEqual(aut_file.node[f]['type'], 'files') - self.assertIn('records', aut_file.node[f]) - self.assertIn('hash', aut_file.node[f]) - self.assertIn('date', aut_file.node[f]) - self.assertNotIn('email', aut_file.node[f]) - self.assertNotIn('fedits', aut_file.node[f]) - self.assertNotIn('weight', aut_file.node[f]) + file_list = ['file1.md', 'file2.md', 'file3.md', 'file4.md', 'file5.md', 'file6.md', 'file7.md'] + for f in file_list: + self.assertIn('id', aut_file.node[f]) + self.assertIn('type', aut_file.node[f]) + self.assertEqual(aut_file.node[f]['type'], 'files') + self.assertIn('records', aut_file.node[f]) + self.assertIn('hash', aut_file.node[f]) + self.assertIn('date', aut_file.node[f]) + self.assertNotIn('email', aut_file.node[f]) + self.assertNotIn('fedits', aut_file.node[f]) + self.assertNotIn('weight', aut_file.node[f]) + + edge_list = [('Marcela', 'file7.md'), ('Marcela', 'file6.md'), + ('Billy G', 'file4.md'), ('Billy G', 'file5.md'), ('Billy G', 'file6.md'), + ('Jenna', 'file3.md'), ('Jenna', 'file5.md'), + ('Randy', 'file1.md'), ('Randy', 'file2.md'), ('Randy', 'file3.md'), ('Randy', 'file4.md'),] + + for n1, n2 in edge_list: + self.assertIn('author', aut_file.edge[n1][n2][0]) + self.assertIn('hash', aut_file.edge[n1][n2][0]) + self.assertNotIn('date', aut_file.edge[n1][n2][0]) + self.assertEqual(len(aut_file.edge[n1][n2]), 1) + self.assertEqual(len(aut_file.edge[n1][n2][0]), 2) + + def test_author_file_weighted(self): + weighted = self.my_log.network(type="author/file/weighted") + + auth_list = ['Marcela', 'Billy G', 'Jenna', 'Randy'] + for a in auth_list: + self.assertIn('id', weighted.node[a]) + self.assertIn('type', weighted.node[a]) + self.assertEqual(weighted.node[a]['type'], 'author') + self.assertIn('records', weighted.node[a]) + self.assertIn('email', weighted.node[a]) + self.assertIn('hash', weighted.node[a]) + self.assertIn('fedits', weighted.node[a]) + self.assertNotIn('weight', weighted.node[a]) + self.assertNotIn('date', weighted.node[a]) + + file_list = ['file1.md', 'file2.md', 'file3.md', 'file4.md', 'file5.md', 'file6.md', 'file7.md'] + for f in file_list: + self.assertIn('id', weighted.node[f]) + self.assertIn('type', weighted.node[f]) + self.assertEqual(weighted.node[f]['type'], 'files') + self.assertIn('records', weighted.node[f]) + self.assertIn('hash', weighted.node[f]) + self.assertIn('date', weighted.node[f]) + self.assertNotIn('email', weighted.node[f]) + self.assertNotIn('fedits', weighted.node[f]) + self.assertNotIn('weight', weighted.node[f]) + + edge_list = [('Marcela', 'file7.md'), ('Marcela', 'file6.md'), + ('Billy G', 'file4.md'), ('Billy G', 'file5.md'), ('Billy G', 'file6.md'), + ('Jenna', 'file3.md'), ('Jenna', 'file5.md'), + ('Randy', 'file1.md'), ('Randy', 'file2.md'), ('Randy', 'file3.md'), ('Randy', 'file4.md'), ] + + for n1, n2 in edge_list: + self.assertIn('author', weighted.edge[n1][n2][0]) + self.assertIn('hash', weighted.edge[n1][n2][0]) + self.assertIn('date', weighted.edge[n1][n2][0]) + self.assertIn('weight', weighted.edge[n1][n2][0]) + self.assertEqual(len(weighted.edge[n1][n2]), 1) + self.assertEqual(len(weighted.edge[n1][n2][0]), 4) + + def test_error(self): + with self.assertRaisesRegex(InputError, 'nonsense is not a valid network preset.'): + self.my_log.network(type="nonsense") + + def tearDown(self): + # Delete temporary .git file + sub.call(["rm", "-rf", ".git"]) + + +if __name__ == '__main__': + unittest.main(buffer=True) +

  • + +
    + + + +
    + + +

    Classes

    + +
    +

    class AnnotateTests

    + + +
    + +
    +
    class AnnotateTests(unittest.TestCase):
    +    def setUp(self):
    +        # Set up small network
    +        sub.call(["cp", "-R", "small_network_repo.git", ".git"])
    +        path = os.getcwd()
    +        self.my_log = gitnet.get_log(path)
    +
    +    def test_utc_date(self):
    +        """Is utc_date being generated correctly?"""
    +        self.assertEqual(self.my_log["7965e62"]["utc_date"],"2016-05-26")
    +        self.assertEqual(self.my_log["6cd4bbf"]["utc_date"],"2016-05-25")
    +        self.assertEqual(self.my_log["ee2c408"]["utc_date"],"2016-05-23")
    +        self.assertEqual(self.my_log["b3a4bac"]["utc_date"],"2016-05-20")
    +
    +    def test_utc_datetime(self):
    +        """Is utc_datetime being generated correctly?"""
    +        self.assertEqual(self.my_log["7965e62"]["utc_datetime"],"2016-05-26 15:21:03")
    +        self.assertEqual(self.my_log["6cd4bbf"]["utc_datetime"],"2016-05-25 05:12:48")
    +        self.assertEqual(self.my_log["ee2c408"]["utc_datetime"],"2016-05-23 06:45:25")
    +        self.assertEqual(self.my_log["b3a4bac"]["utc_datetime"],"2016-05-20 13:19:20")
    +
    +    def test_domain(self):
    +        """Is domain being generated correctly?"""
    +        self.assertEqual(self.my_log["7965e62"]["domain"],"gmail")
    +        self.assertEqual(self.my_log["6cd4bbf"]["domain"],"gmail")
    +        self.assertEqual(self.my_log["ee2c408"]["domain"],"gmail")
    +        self.assertEqual(self.my_log["b3a4bac"]["domain"],"gmail")
    +
    +    def tearDown(self):
    +        # Delete temporary .git file
    +        sub.call(["rm", "-rf", ".git"])
    +
    + +
    +
    + + +
    +

    Ancestors (in MRO)

    + +

    Class variables

    +
    +

    var failureException

    + + + + +
    +
    + +
    +
    +

    var longMessage

    + + + + +
    +
    + +
    +
    +

    var maxDiff

    + + + + +
    +
    + +
    +

    Static methods

    + +
    +
    +

    def __init__(

    self, methodName='runTest')

    +
    + + + + +

    Create an instance of the class that will use the named test +method when executed. Raises a ValueError if the instance does +not have a method with the specified name.

    +
    + +
    +
    def __init__(self, methodName='runTest'):
    +    """Create an instance of the class that will use the named test
    +       method when executed. Raises a ValueError if the instance does
    +       not have a method with the specified name.
    +    """
    +    self._testMethodName = methodName
    +    self._outcome = None
    +    self._testMethodDoc = 'No test'
    +    try:
    +        testMethod = getattr(self, methodName)
    +    except AttributeError:
    +        if methodName != 'runTest':
    +            # we allow instantiation with no explicit method name
    +            # but not an *incorrect* or missing method name
    +            raise ValueError("no such test method in %s: %s" %
    +                  (self.__class__, methodName))
    +    else:
    +        self._testMethodDoc = testMethod.__doc__
    +    self._cleanups = []
    +    self._subtest = None
    +    # Map types to custom assertEqual functions that will compare
    +    # instances of said type in more detail to generate a more useful
    +    # error message.
    +    self._type_equality_funcs = {}
    +    self.addTypeEqualityFunc(dict, 'assertDictEqual')
    +    self.addTypeEqualityFunc(list, 'assertListEqual')
    +    self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
    +    self.addTypeEqualityFunc(set, 'assertSetEqual')
    +    self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
    +    self.addTypeEqualityFunc(str, 'assertMultiLineEqual')
    +
    + +
    +
    + +
    + + +
    +
    +

    def addCleanup(

    self, function, *args, **kwargs)

    +
    + + + + +

    Add a function, with arguments, to be called when the test is +completed. Functions added are called on a LIFO basis and are +called after tearDown on test failure or success.

    +

    Cleanup items are called even if setUp fails (unlike tearDown).

    +
    + +
    +
    def addCleanup(self, function, *args, **kwargs):
    +    """Add a function, with arguments, to be called when the test is
    +    completed. Functions added are called on a LIFO basis and are
    +    called after tearDown on test failure or success.
    +    Cleanup items are called even if setUp fails (unlike tearDown)."""
    +    self._cleanups.append((function, args, kwargs))
    +
    + +
    +
    + +
    + + +
    +
    +

    def addTypeEqualityFunc(

    self, typeobj, function)

    +
    + + + + +

    Add a type specific assertEqual style function to compare a type.

    +

    This method is for use by TestCase subclasses that need to register +their own type equality functions to provide nicer error messages.

    +

    Args: + typeobj: The data type to call this function on when both values + are of the same type in assertEqual(). + function: The callable taking two arguments and an optional + msg= argument that raises self.failureException with a + useful error message when the two arguments are not equal.

    +
    + +
    +
    def addTypeEqualityFunc(self, typeobj, function):
    +    """Add a type specific assertEqual style function to compare a type.
    +    This method is for use by TestCase subclasses that need to register
    +    their own type equality functions to provide nicer error messages.
    +    Args:
    +        typeobj: The data type to call this function on when both values
    +                are of the same type in assertEqual().
    +        function: The callable taking two arguments and an optional
    +                msg= argument that raises self.failureException with a
    +                useful error message when the two arguments are not equal.
    +    """
    +    self._type_equality_funcs[typeobj] = function
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertAlmostEqual(

    self, first, second, places=None, msg=None, delta=None)

    +
    + + + + +

    Fail if the two objects are unequal as determined by their +difference rounded to the given number of decimal places +(default 7) and comparing to zero, or by comparing that the +between the two objects is more than the given delta.

    +

    Note that decimal places (from zero) are usually not the same +as significant digits (measured from the most signficant digit).

    +

    If the two objects compare equal then they will automatically +compare almost equal.

    +
    + +
    +
    def assertAlmostEqual(self, first, second, places=None, msg=None,
    +                      delta=None):
    +    """Fail if the two objects are unequal as determined by their
    +       difference rounded to the given number of decimal places
    +       (default 7) and comparing to zero, or by comparing that the
    +       between the two objects is more than the given delta.
    +       Note that decimal places (from zero) are usually not the same
    +       as significant digits (measured from the most signficant digit).
    +       If the two objects compare equal then they will automatically
    +       compare almost equal.
    +    """
    +    if first == second:
    +        # shortcut
    +        return
    +    if delta is not None and places is not None:
    +        raise TypeError("specify delta or places not both")
    +    if delta is not None:
    +        if abs(first - second) <= delta:
    +            return
    +        standardMsg = '%s != %s within %s delta' % (safe_repr(first),
    +                                                    safe_repr(second),
    +                                                    safe_repr(delta))
    +    else:
    +        if places is None:
    +            places = 7
    +        if round(abs(second-first), places) == 0:
    +            return
    +        standardMsg = '%s != %s within %r places' % (safe_repr(first),
    +                                                      safe_repr(second),
    +                                                      places)
    +    msg = self._formatMessage(msg, standardMsg)
    +    raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertAlmostEquals(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertCountEqual(

    self, first, second, msg=None)

    +
    + + + + +

    An unordered sequence comparison asserting that the same elements, +regardless of order. If the same element occurs more than once, +it verifies that the elements occur the same number of times.

    +
    self.assertEqual(Counter(list(first)),
    +                 Counter(list(second)))
    +
    + + +

    Example: + - [0, 1, 1] and [1, 0, 1] compare equal. + - [0, 0, 1] and [0, 1] compare unequal.

    +
    + +
    +
    def assertCountEqual(self, first, second, msg=None):
    +    """An unordered sequence comparison asserting that the same elements,
    +    regardless of order.  If the same element occurs more than once,
    +    it verifies that the elements occur the same number of times.
    +        self.assertEqual(Counter(list(first)),
    +                         Counter(list(second)))
    +     Example:
    +        - [0, 1, 1] and [1, 0, 1] compare equal.
    +        - [0, 0, 1] and [0, 1] compare unequal.
    +    """
    +    first_seq, second_seq = list(first), list(second)
    +    try:
    +        first = collections.Counter(first_seq)
    +        second = collections.Counter(second_seq)
    +    except TypeError:
    +        # Handle case with unhashable elements
    +        differences = _count_diff_all_purpose(first_seq, second_seq)
    +    else:
    +        if first == second:
    +            return
    +        differences = _count_diff_hashable(first_seq, second_seq)
    +    if differences:
    +        standardMsg = 'Element counts were not equal:\n'
    +        lines = ['First has %d, Second has %d:  %r' % diff for diff in differences]
    +        diffMsg = '\n'.join(lines)
    +        standardMsg = self._truncateMessage(standardMsg, diffMsg)
    +        msg = self._formatMessage(msg, standardMsg)
    +        self.fail(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertDictContainsSubset(

    self, subset, dictionary, msg=None)

    +
    + + + + +

    Checks whether dictionary is a superset of subset.

    +
    + +
    +
    def assertDictContainsSubset(self, subset, dictionary, msg=None):
    +    """Checks whether dictionary is a superset of subset."""
    +    warnings.warn('assertDictContainsSubset is deprecated',
    +                  DeprecationWarning)
    +    missing = []
    +    mismatched = []
    +    for key, value in subset.items():
    +        if key not in dictionary:
    +            missing.append(key)
    +        elif value != dictionary[key]:
    +            mismatched.append('%s, expected: %s, actual: %s' %
    +                              (safe_repr(key), safe_repr(value),
    +                               safe_repr(dictionary[key])))
    +    if not (missing or mismatched):
    +        return
    +    standardMsg = ''
    +    if missing:
    +        standardMsg = 'Missing: %s' % ','.join(safe_repr(m) for m in
    +                                                missing)
    +    if mismatched:
    +        if standardMsg:
    +            standardMsg += '; '
    +        standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
    +    self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertDictEqual(

    self, d1, d2, msg=None)

    +
    + + + + +
    + +
    +
    def assertDictEqual(self, d1, d2, msg=None):
    +    self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
    +    self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
    +    if d1 != d2:
    +        standardMsg = '%s != %s' % _common_shorten_repr(d1, d2)
    +        diff = ('\n' + '\n'.join(difflib.ndiff(
    +                       pprint.pformat(d1).splitlines(),
    +                       pprint.pformat(d2).splitlines())))
    +        standardMsg = self._truncateMessage(standardMsg, diff)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertEqual(

    self, first, second, msg=None)

    +
    + + + + +

    Fail if the two objects are unequal as determined by the '==' +operator.

    +
    + +
    +
    def assertEqual(self, first, second, msg=None):
    +    """Fail if the two objects are unequal as determined by the '=='
    +       operator.
    +    """
    +    assertion_func = self._getAssertEqualityFunc(first, second)
    +    assertion_func(first, second, msg=msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertEquals(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertFalse(

    self, expr, msg=None)

    +
    + + + + +

    Check that the expression is false.

    +
    + +
    +
    def assertFalse(self, expr, msg=None):
    +    """Check that the expression is false."""
    +    if expr:
    +        msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertGreater(

    self, a, b, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a > b), but with a nicer default message.

    +
    + +
    +
    def assertGreater(self, a, b, msg=None):
    +    """Just like self.assertTrue(a > b), but with a nicer default message."""
    +    if not a > b:
    +        standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertGreaterEqual(

    self, a, b, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a >= b), but with a nicer default message.

    +
    + +
    +
    def assertGreaterEqual(self, a, b, msg=None):
    +    """Just like self.assertTrue(a >= b), but with a nicer default message."""
    +    if not a >= b:
    +        standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIn(

    self, member, container, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a in b), but with a nicer default message.

    +
    + +
    +
    def assertIn(self, member, container, msg=None):
    +    """Just like self.assertTrue(a in b), but with a nicer default message."""
    +    if member not in container:
    +        standardMsg = '%s not found in %s' % (safe_repr(member),
    +                                              safe_repr(container))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIs(

    self, expr1, expr2, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a is b), but with a nicer default message.

    +
    + +
    +
    def assertIs(self, expr1, expr2, msg=None):
    +    """Just like self.assertTrue(a is b), but with a nicer default message."""
    +    if expr1 is not expr2:
    +        standardMsg = '%s is not %s' % (safe_repr(expr1),
    +                                         safe_repr(expr2))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIsInstance(

    self, obj, cls, msg=None)

    +
    + + + + +

    Same as self.assertTrue(isinstance(obj, cls)), with a nicer +default message.

    +
    + +
    +
    def assertIsInstance(self, obj, cls, msg=None):
    +    """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
    +    default message."""
    +    if not isinstance(obj, cls):
    +        standardMsg = '%s is not an instance of %r' % (safe_repr(obj), cls)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIsNone(

    self, obj, msg=None)

    +
    + + + + +

    Same as self.assertTrue(obj is None), with a nicer default message.

    +
    + +
    +
    def assertIsNone(self, obj, msg=None):
    +    """Same as self.assertTrue(obj is None), with a nicer default message."""
    +    if obj is not None:
    +        standardMsg = '%s is not None' % (safe_repr(obj),)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIsNot(

    self, expr1, expr2, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a is not b), but with a nicer default message.

    +
    + +
    +
    def assertIsNot(self, expr1, expr2, msg=None):
    +    """Just like self.assertTrue(a is not b), but with a nicer default message."""
    +    if expr1 is expr2:
    +        standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIsNotNone(

    self, obj, msg=None)

    +
    + + + + +

    Included for symmetry with assertIsNone.

    +
    + +
    +
    def assertIsNotNone(self, obj, msg=None):
    +    """Included for symmetry with assertIsNone."""
    +    if obj is None:
    +        standardMsg = 'unexpectedly None'
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertLess(

    self, a, b, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a < b), but with a nicer default message.

    +
    + +
    +
    def assertLess(self, a, b, msg=None):
    +    """Just like self.assertTrue(a < b), but with a nicer default message."""
    +    if not a < b:
    +        standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertLessEqual(

    self, a, b, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a <= b), but with a nicer default message.

    +
    + +
    +
    def assertLessEqual(self, a, b, msg=None):
    +    """Just like self.assertTrue(a <= b), but with a nicer default message."""
    +    if not a <= b:
    +        standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertListEqual(

    self, list1, list2, msg=None)

    +
    + + + + +

    A list-specific equality assertion.

    +

    Args: + list1: The first list to compare. + list2: The second list to compare. + msg: Optional message to use on failure instead of a list of + differences.

    +
    + +
    +
    def assertListEqual(self, list1, list2, msg=None):
    +    """A list-specific equality assertion.
    +    Args:
    +        list1: The first list to compare.
    +        list2: The second list to compare.
    +        msg: Optional message to use on failure instead of a list of
    +                differences.
    +    """
    +    self.assertSequenceEqual(list1, list2, msg, seq_type=list)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertLogs(

    self, logger=None, level=None)

    +
    + + + + +

    Fail unless a log message of level level or higher is emitted +on logger_name or its children. If omitted, level defaults to +INFO and logger defaults to the root logger.

    +

    This method must be used as a context manager, and will yield +a recording object with two attributes: output and records. +At the end of the context manager, the output attribute will +be a list of the matching formatted log messages and the +records attribute will be a list of the corresponding LogRecord +objects.

    +

    Example::

    +
    with self.assertLogs('foo', level='INFO') as cm:
    +    logging.getLogger('foo').info('first message')
    +    logging.getLogger('foo.bar').error('second message')
    +self.assertEqual(cm.output, ['INFO:foo:first message',
    +                             'ERROR:foo.bar:second message'])
    +
    +
    + +
    +
    def assertLogs(self, logger=None, level=None):
    +    """Fail unless a log message of level *level* or higher is emitted
    +    on *logger_name* or its children.  If omitted, *level* defaults to
    +    INFO and *logger* defaults to the root logger.
    +    This method must be used as a context manager, and will yield
    +    a recording object with two attributes: `output` and `records`.
    +    At the end of the context manager, the `output` attribute will
    +    be a list of the matching formatted log messages and the
    +    `records` attribute will be a list of the corresponding LogRecord
    +    objects.
    +    Example::
    +        with self.assertLogs('foo', level='INFO') as cm:
    +            logging.getLogger('foo').info('first message')
    +            logging.getLogger('foo.bar').error('second message')
    +        self.assertEqual(cm.output, ['INFO:foo:first message',
    +                                     'ERROR:foo.bar:second message'])
    +    """
    +    return _AssertLogsContext(self, logger, level)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertMultiLineEqual(

    self, first, second, msg=None)

    +
    + + + + +

    Assert that two multi-line strings are equal.

    +
    + +
    +
    def assertMultiLineEqual(self, first, second, msg=None):
    +    """Assert that two multi-line strings are equal."""
    +    self.assertIsInstance(first, str, 'First argument is not a string')
    +    self.assertIsInstance(second, str, 'Second argument is not a string')
    +    if first != second:
    +        # don't use difflib if the strings are too long
    +        if (len(first) > self._diffThreshold or
    +            len(second) > self._diffThreshold):
    +            self._baseAssertEqual(first, second, msg)
    +        firstlines = first.splitlines(keepends=True)
    +        secondlines = second.splitlines(keepends=True)
    +        if len(firstlines) == 1 and first.strip('\r\n') == first:
    +            firstlines = [first + '\n']
    +            secondlines = [second + '\n']
    +        standardMsg = '%s != %s' % _common_shorten_repr(first, second)
    +        diff = '\n' + ''.join(difflib.ndiff(firstlines, secondlines))
    +        standardMsg = self._truncateMessage(standardMsg, diff)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotAlmostEqual(

    self, first, second, places=None, msg=None, delta=None)

    +
    + + + + +

    Fail if the two objects are equal as determined by their +difference rounded to the given number of decimal places +(default 7) and comparing to zero, or by comparing that the +between the two objects is less than the given delta.

    +

    Note that decimal places (from zero) are usually not the same +as significant digits (measured from the most signficant digit).

    +

    Objects that are equal automatically fail.

    +
    + +
    +
    def assertNotAlmostEqual(self, first, second, places=None, msg=None,
    +                         delta=None):
    +    """Fail if the two objects are equal as determined by their
    +       difference rounded to the given number of decimal places
    +       (default 7) and comparing to zero, or by comparing that the
    +       between the two objects is less than the given delta.
    +       Note that decimal places (from zero) are usually not the same
    +       as significant digits (measured from the most signficant digit).
    +       Objects that are equal automatically fail.
    +    """
    +    if delta is not None and places is not None:
    +        raise TypeError("specify delta or places not both")
    +    if delta is not None:
    +        if not (first == second) and abs(first - second) > delta:
    +            return
    +        standardMsg = '%s == %s within %s delta' % (safe_repr(first),
    +                                                    safe_repr(second),
    +                                                    safe_repr(delta))
    +    else:
    +        if places is None:
    +            places = 7
    +        if not (first == second) and round(abs(second-first), places) != 0:
    +            return
    +        standardMsg = '%s == %s within %r places' % (safe_repr(first),
    +                                                     safe_repr(second),
    +                                                     places)
    +    msg = self._formatMessage(msg, standardMsg)
    +    raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotAlmostEquals(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotEqual(

    self, first, second, msg=None)

    +
    + + + + +

    Fail if the two objects are equal as determined by the '!=' +operator.

    +
    + +
    +
    def assertNotEqual(self, first, second, msg=None):
    +    """Fail if the two objects are equal as determined by the '!='
    +       operator.
    +    """
    +    if not first != second:
    +        msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first),
    +                                                      safe_repr(second)))
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotEquals(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotIn(

    self, member, container, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a not in b), but with a nicer default message.

    +
    + +
    +
    def assertNotIn(self, member, container, msg=None):
    +    """Just like self.assertTrue(a not in b), but with a nicer default message."""
    +    if member in container:
    +        standardMsg = '%s unexpectedly found in %s' % (safe_repr(member),
    +                                                    safe_repr(container))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotIsInstance(

    self, obj, cls, msg=None)

    +
    + + + + +

    Included for symmetry with assertIsInstance.

    +
    + +
    +
    def assertNotIsInstance(self, obj, cls, msg=None):
    +    """Included for symmetry with assertIsInstance."""
    +    if isinstance(obj, cls):
    +        standardMsg = '%s is an instance of %r' % (safe_repr(obj), cls)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotRegex(

    self, text, unexpected_regex, msg=None)

    +
    + + + + +

    Fail the test if the text matches the regular expression.

    +
    + +
    +
    def assertNotRegex(self, text, unexpected_regex, msg=None):
    +    """Fail the test if the text matches the regular expression."""
    +    if isinstance(unexpected_regex, (str, bytes)):
    +        unexpected_regex = re.compile(unexpected_regex)
    +    match = unexpected_regex.search(text)
    +    if match:
    +        msg = msg or "Regex matched"
    +        msg = '%s: %r matches %r in %r' % (msg,
    +                                           text[match.start():match.end()],
    +                                           unexpected_regex.pattern,
    +                                           text)
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    +
    + + + + +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is +raised, it will not be caught, and the test case will be +deemed to have suffered an error, exactly as for an +unexpected exception.

    +

    If called with callableObj omitted or None, will return a +context object used like this::

    +
     with self.assertRaises(SomeException):
    +     do_something()
    +
    + + +

    An optional keyword argument 'msg' can be provided when assertRaises +is used as a context object.

    +

    The context manager keeps a reference to the exception as +the 'exception' attribute. This allows you to inspect the +exception after the assertion::

    +
    with self.assertRaises(SomeException) as cm:
    +    do_something()
    +the_exception = cm.exception
    +self.assertEqual(the_exception.error_code, 3)
    +
    +
    + +
    +
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
    +       raised, it will not be caught, and the test case will be
    +       deemed to have suffered an error, exactly as for an
    +       unexpected exception.
    +       If called with callableObj omitted or None, will return a
    +       context object used like this::
    +            with self.assertRaises(SomeException):
    +                do_something()
    +       An optional keyword argument 'msg' can be provided when assertRaises
    +       is used as a context object.
    +       The context manager keeps a reference to the exception as
    +       the 'exception' attribute. This allows you to inspect the
    +       exception after the assertion::
    +           with self.assertRaises(SomeException) as cm:
    +               do_something()
    +           the_exception = cm.exception
    +           self.assertEqual(the_exception.error_code, 3)
    +    """
    +    context = _AssertRaisesContext(excClass, self, callableObj)
    +    return context.handle('assertRaises', callableObj, args, kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    +
    + + + + +

    Asserts that the message in a raised exception matches a regex.

    +

    Args: + expected_exception: Exception class expected to be raised. + expected_regex: Regex (re pattern object or string) expected + to be found in error message. + callable_obj: Function to be called. + msg: Optional message used in case of failure. Can only be used + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    +
    + +
    +
    def assertRaisesRegex(self, expected_exception, expected_regex,
    +                      callable_obj=None, *args, **kwargs):
    +    """Asserts that the message in a raised exception matches a regex.
    +    Args:
    +        expected_exception: Exception class expected to be raised.
    +        expected_regex: Regex (re pattern object or string) expected
    +                to be found in error message.
    +        callable_obj: Function to be called.
    +        msg: Optional message used in case of failure. Can only be used
    +                when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
    +    """
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRaisesRegexp(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRegex(

    self, text, expected_regex, msg=None)

    +
    + + + + +

    Fail the test unless the text matches the regular expression.

    +
    + +
    +
    def assertRegex(self, text, expected_regex, msg=None):
    +    """Fail the test unless the text matches the regular expression."""
    +    if isinstance(expected_regex, (str, bytes)):
    +        assert expected_regex, "expected_regex must not be empty."
    +        expected_regex = re.compile(expected_regex)
    +    if not expected_regex.search(text):
    +        msg = msg or "Regex didn't match"
    +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRegexpMatches(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertSequenceEqual(

    self, seq1, seq2, msg=None, seq_type=None)

    +
    + + + + +

    An equality assertion for ordered sequences (like lists and tuples).

    +

    For the purposes of this function, a valid ordered sequence type is one +which can be indexed, has a length, and has an equality operator.

    +

    Args: + seq1: The first sequence to compare. + seq2: The second sequence to compare. + seq_type: The expected datatype of the sequences, or None if no + datatype should be enforced. + msg: Optional message to use on failure instead of a list of + differences.

    +
    + +
    +
    def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
    +    """An equality assertion for ordered sequences (like lists and tuples).
    +    For the purposes of this function, a valid ordered sequence type is one
    +    which can be indexed, has a length, and has an equality operator.
    +    Args:
    +        seq1: The first sequence to compare.
    +        seq2: The second sequence to compare.
    +        seq_type: The expected datatype of the sequences, or None if no
    +                datatype should be enforced.
    +        msg: Optional message to use on failure instead of a list of
    +                differences.
    +    """
    +    if seq_type is not None:
    +        seq_type_name = seq_type.__name__
    +        if not isinstance(seq1, seq_type):
    +            raise self.failureException('First sequence is not a %s: %s'
    +                                    % (seq_type_name, safe_repr(seq1)))
    +        if not isinstance(seq2, seq_type):
    +            raise self.failureException('Second sequence is not a %s: %s'
    +                                    % (seq_type_name, safe_repr(seq2)))
    +    else:
    +        seq_type_name = "sequence"
    +    differing = None
    +    try:
    +        len1 = len(seq1)
    +    except (TypeError, NotImplementedError):
    +        differing = 'First %s has no length.    Non-sequence?' % (
    +                seq_type_name)
    +    if differing is None:
    +        try:
    +            len2 = len(seq2)
    +        except (TypeError, NotImplementedError):
    +            differing = 'Second %s has no length.    Non-sequence?' % (
    +                    seq_type_name)
    +    if differing is None:
    +        if seq1 == seq2:
    +            return
    +        differing = '%ss differ: %s != %s\n' % (
    +                (seq_type_name.capitalize(),) +
    +                _common_shorten_repr(seq1, seq2))
    +        for i in range(min(len1, len2)):
    +            try:
    +                item1 = seq1[i]
    +            except (TypeError, IndexError, NotImplementedError):
    +                differing += ('\nUnable to index element %d of first %s\n' %
    +                             (i, seq_type_name))
    +                break
    +            try:
    +                item2 = seq2[i]
    +            except (TypeError, IndexError, NotImplementedError):
    +                differing += ('\nUnable to index element %d of second %s\n' %
    +                             (i, seq_type_name))
    +                break
    +            if item1 != item2:
    +                differing += ('\nFirst differing element %d:\n%s\n%s\n' %
    +                             (i, item1, item2))
    +                break
    +        else:
    +            if (len1 == len2 and seq_type is None and
    +                type(seq1) != type(seq2)):
    +                # The sequences are the same, but have differing types.
    +                return
    +        if len1 > len2:
    +            differing += ('\nFirst %s contains %d additional '
    +                         'elements.\n' % (seq_type_name, len1 - len2))
    +            try:
    +                differing += ('First extra element %d:\n%s\n' %
    +                              (len2, seq1[len2]))
    +            except (TypeError, IndexError, NotImplementedError):
    +                differing += ('Unable to index element %d '
    +                              'of first %s\n' % (len2, seq_type_name))
    +        elif len1 < len2:
    +            differing += ('\nSecond %s contains %d additional '
    +                         'elements.\n' % (seq_type_name, len2 - len1))
    +            try:
    +                differing += ('First extra element %d:\n%s\n' %
    +                              (len1, seq2[len1]))
    +            except (TypeError, IndexError, NotImplementedError):
    +                differing += ('Unable to index element %d '
    +                              'of second %s\n' % (len1, seq_type_name))
    +    standardMsg = differing
    +    diffMsg = '\n' + '\n'.join(
    +        difflib.ndiff(pprint.pformat(seq1).splitlines(),
    +                      pprint.pformat(seq2).splitlines()))
    +    standardMsg = self._truncateMessage(standardMsg, diffMsg)
    +    msg = self._formatMessage(msg, standardMsg)
    +    self.fail(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertSetEqual(

    self, set1, set2, msg=None)

    +
    + + + + +

    A set-specific equality assertion.

    +

    Args: + set1: The first set to compare. + set2: The second set to compare. + msg: Optional message to use on failure instead of a list of + differences.

    +

    assertSetEqual uses ducktyping to support different types of sets, and +is optimized for sets specifically (parameters must support a +difference method).

    +
    + +
    +
    def assertSetEqual(self, set1, set2, msg=None):
    +    """A set-specific equality assertion.
    +    Args:
    +        set1: The first set to compare.
    +        set2: The second set to compare.
    +        msg: Optional message to use on failure instead of a list of
    +                differences.
    +    assertSetEqual uses ducktyping to support different types of sets, and
    +    is optimized for sets specifically (parameters must support a
    +    difference method).
    +    """
    +    try:
    +        difference1 = set1.difference(set2)
    +    except TypeError as e:
    +        self.fail('invalid type when attempting set difference: %s' % e)
    +    except AttributeError as e:
    +        self.fail('first argument does not support set difference: %s' % e)
    +    try:
    +        difference2 = set2.difference(set1)
    +    except TypeError as e:
    +        self.fail('invalid type when attempting set difference: %s' % e)
    +    except AttributeError as e:
    +        self.fail('second argument does not support set difference: %s' % e)
    +    if not (difference1 or difference2):
    +        return
    +    lines = []
    +    if difference1:
    +        lines.append('Items in the first set but not the second:')
    +        for item in difference1:
    +            lines.append(repr(item))
    +    if difference2:
    +        lines.append('Items in the second set but not the first:')
    +        for item in difference2:
    +            lines.append(repr(item))
    +    standardMsg = '\n'.join(lines)
    +    self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertTrue(

    self, expr, msg=None)

    +
    + + + + +

    Check that the expression is true.

    +
    + +
    +
    def assertTrue(self, expr, msg=None):
    +    """Check that the expression is true."""
    +    if not expr:
    +        msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertTupleEqual(

    self, tuple1, tuple2, msg=None)

    +
    + + + + +

    A tuple-specific equality assertion.

    +

    Args: + tuple1: The first tuple to compare. + tuple2: The second tuple to compare. + msg: Optional message to use on failure instead of a list of + differences.

    +
    + +
    +
    def assertTupleEqual(self, tuple1, tuple2, msg=None):
    +    """A tuple-specific equality assertion.
    +    Args:
    +        tuple1: The first tuple to compare.
    +        tuple2: The second tuple to compare.
    +        msg: Optional message to use on failure instead of a list of
    +                differences.
    +    """
    +    self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    +
    + + + + +

    Fail unless a warning of class warnClass is triggered +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is +triggered, it will not be handled: depending on the other +warning filtering rules in effect, it might be silenced, printed +out, or raised as an exception.

    +

    If called with callable_obj omitted or None, will return a +context object used like this::

    +
     with self.assertWarns(SomeWarning):
    +     do_something()
    +
    + + +

    An optional keyword argument 'msg' can be provided when assertWarns +is used as a context object.

    +

    The context manager keeps a reference to the first matching +warning as the 'warning' attribute; similarly, the 'filename' +and 'lineno' attributes give you information about the line +of Python code from which the warning was triggered. +This allows you to inspect the warning after the assertion::

    +
    with self.assertWarns(SomeWarning) as cm:
    +    do_something()
    +the_warning = cm.warning
    +self.assertEqual(the_warning.some_attribute, 147)
    +
    +
    + +
    +
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
    +    """Fail unless a warning of class warnClass is triggered
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
    +       triggered, it will not be handled: depending on the other
    +       warning filtering rules in effect, it might be silenced, printed
    +       out, or raised as an exception.
    +       If called with callable_obj omitted or None, will return a
    +       context object used like this::
    +            with self.assertWarns(SomeWarning):
    +                do_something()
    +       An optional keyword argument 'msg' can be provided when assertWarns
    +       is used as a context object.
    +       The context manager keeps a reference to the first matching
    +       warning as the 'warning' attribute; similarly, the 'filename'
    +       and 'lineno' attributes give you information about the line
    +       of Python code from which the warning was triggered.
    +       This allows you to inspect the warning after the assertion::
    +           with self.assertWarns(SomeWarning) as cm:
    +               do_something()
    +           the_warning = cm.warning
    +           self.assertEqual(the_warning.some_attribute, 147)
    +    """
    +    context = _AssertWarnsContext(expected_warning, self, callable_obj)
    +    return context.handle('assertWarns', callable_obj, args, kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    +
    + + + + +

    Asserts that the message in a triggered warning matches a regexp. +Basic functioning is similar to assertWarns() with the addition +that only warnings whose messages also match the regular expression +are considered successful matches.

    +

    Args: + expected_warning: Warning class expected to be triggered. + expected_regex: Regex (re pattern object or string) expected + to be found in error message. + callable_obj: Function to be called. + msg: Optional message used in case of failure. Can only be used + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    +
    + +
    +
    def assertWarnsRegex(self, expected_warning, expected_regex,
    +                     callable_obj=None, *args, **kwargs):
    +    """Asserts that the message in a triggered warning matches a regexp.
    +    Basic functioning is similar to assertWarns() with the addition
    +    that only warnings whose messages also match the regular expression
    +    are considered successful matches.
    +    Args:
    +        expected_warning: Warning class expected to be triggered.
    +        expected_regex: Regex (re pattern object or string) expected
    +                to be found in error message.
    +        callable_obj: Function to be called.
    +        msg: Optional message used in case of failure. Can only be used
    +                when assertWarnsRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
    +    """
    +    context = _AssertWarnsContext(expected_warning, self, callable_obj,
    +                                  expected_regex)
    +    return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assert_(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def countTestCases(

    self)

    +
    + + + + +
    + +
    +
    def countTestCases(self):
    +    return 1
    +
    + +
    +
    + +
    + + +
    +
    +

    def debug(

    self)

    +
    + + + + +

    Run the test without collecting errors in a TestResult

    +
    + +
    +
    def debug(self):
    +    """Run the test without collecting errors in a TestResult"""
    +    self.setUp()
    +    getattr(self, self._testMethodName)()
    +    self.tearDown()
    +    while self._cleanups:
    +        function, args, kwargs = self._cleanups.pop(-1)
    +        function(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def defaultTestResult(

    self)

    +
    + + + + +
    + +
    +
    def defaultTestResult(self):
    +    return result.TestResult()
    +
    + +
    +
    + +
    + + +
    +
    +

    def doCleanups(

    self)

    +
    + + + + +

    Execute all cleanup functions. Normally called for you after +tearDown.

    +
    + +
    +
    def doCleanups(self):
    +    """Execute all cleanup functions. Normally called for you after
    +    tearDown."""
    +    outcome = self._outcome or _Outcome()
    +    while self._cleanups:
    +        function, args, kwargs = self._cleanups.pop()
    +        with outcome.testPartExecutor(self):
    +            function(*args, **kwargs)
    +    # return this for backwards compatibility
    +    # even though we no longer us it internally
    +    return outcome.success
    +
    + +
    +
    + +
    + + +
    +
    +

    def fail(

    self, msg=None)

    +
    + + + + +

    Fail immediately, with the given message.

    +
    + +
    +
    def fail(self, msg=None):
    +    """Fail immediately, with the given message."""
    +    raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failIf(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failIfAlmostEqual(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failIfEqual(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failUnless(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failUnlessAlmostEqual(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failUnlessEqual(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failUnlessRaises(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def id(

    self)

    +
    + + + + +
    + +
    +
    def id(self):
    +    return "%s.%s" % (strclass(self.__class__), self._testMethodName)
    +
    + +
    +
    + +
    + + +
    +
    +

    def run(

    self, result=None)

    +
    + + + + +
    + +
    +
    def run(self, result=None):
    +    orig_result = result
    +    if result is None:
    +        result = self.defaultTestResult()
    +        startTestRun = getattr(result, 'startTestRun', None)
    +        if startTestRun is not None:
    +            startTestRun()
    +    result.startTest(self)
    +    testMethod = getattr(self, self._testMethodName)
    +    if (getattr(self.__class__, "__unittest_skip__", False) or
    +        getattr(testMethod, "__unittest_skip__", False)):
    +        # If the class or method was skipped.
    +        try:
    +            skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
    +                        or getattr(testMethod, '__unittest_skip_why__', ''))
    +            self._addSkip(result, self, skip_why)
    +        finally:
    +            result.stopTest(self)
    +        return
    +    expecting_failure_method = getattr(testMethod,
    +                                       "__unittest_expecting_failure__", False)
    +    expecting_failure_class = getattr(self,
    +                                      "__unittest_expecting_failure__", False)
    +    expecting_failure = expecting_failure_class or expecting_failure_method
    +    outcome = _Outcome(result)
    +    try:
    +        self._outcome = outcome
    +        with outcome.testPartExecutor(self):
    +            self.setUp()
    +        if outcome.success:
    +            outcome.expecting_failure = expecting_failure
    +            with outcome.testPartExecutor(self, isTest=True):
    +                testMethod()
    +            outcome.expecting_failure = False
    +            with outcome.testPartExecutor(self):
    +                self.tearDown()
    +        self.doCleanups()
    +        for test, reason in outcome.skipped:
    +            self._addSkip(result, test, reason)
    +        self._feedErrorsToResult(result, outcome.errors)
    +        if outcome.success:
    +            if expecting_failure:
    +                if outcome.expectedFailure:
    +                    self._addExpectedFailure(result, outcome.expectedFailure)
    +                else:
    +                    self._addUnexpectedSuccess(result)
    +            else:
    +                result.addSuccess(self)
    +        return result
    +    finally:
    +        result.stopTest(self)
    +        if orig_result is None:
    +            stopTestRun = getattr(result, 'stopTestRun', None)
    +            if stopTestRun is not None:
    +                stopTestRun()
    +        # explicitly break reference cycles:
    +        # outcome.errors -> frame -> outcome -> outcome.errors
    +        # outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure
    +        outcome.errors.clear()
    +        outcome.expectedFailure = None
    +        # clear the outcome, no more needed
    +        self._outcome = None
    +
    + +
    +
    + +
    + + +
    +
    +

    def setUp(

    self)

    +
    + + + + +
    + +
    +
    def setUp(self):
    +    # Set up small network
    +    sub.call(["cp", "-R", "small_network_repo.git", ".git"])
    +    path = os.getcwd()
    +    self.my_log = gitnet.get_log(path)
    +
    + +
    +
    + +
    + + +
    +
    +

    def shortDescription(

    self)

    +
    + + + + +

    Returns a one-line description of the test, or None if no +description has been provided.

    +

    The default implementation of this method returns the first line of +the specified test method's docstring.

    +
    + +
    +
    def shortDescription(self):
    +    """Returns a one-line description of the test, or None if no
    +    description has been provided.
    +    The default implementation of this method returns the first line of
    +    the specified test method's docstring.
    +    """
    +    doc = self._testMethodDoc
    +    return doc and doc.split("\n")[0].strip() or None
    +
    + +
    +
    + +
    + + +
    +
    +

    def skipTest(

    self, reason)

    +
    + + + + +

    Skip this test.

    +
    + +
    +
    def skipTest(self, reason):
    +    """Skip this test."""
    +    raise SkipTest(reason)
    +
    + +
    +
    + +
    + + +
    +
    +

    def subTest(

    *args, **kwds)

    +
    + + + + +

    Return a context manager that will return the enclosed block +of code in a subtest identified by the optional message and +keyword parameters. A failure in the subtest marks the test +case as failed but resumes execution at the end of the enclosed +block, allowing further test code to be executed.

    +
    + +
    +
    @contextlib.contextmanager
    +def subTest(self, msg=None, **params):
    +    """Return a context manager that will return the enclosed block
    +    of code in a subtest identified by the optional message and
    +    keyword parameters.  A failure in the subtest marks the test
    +    case as failed but resumes execution at the end of the enclosed
    +    block, allowing further test code to be executed.
    +    """
    +    if not self._outcome.result_supports_subtests:
    +        yield
    +        return
    +    parent = self._subtest
    +    if parent is None:
    +        params_map = collections.ChainMap(params)
    +    else:
    +        params_map = parent.params.new_child(params)
    +    self._subtest = _SubTest(self, msg, params_map)
    +    try:
    +        with self._outcome.testPartExecutor(self._subtest, isTest=True):
    +            yield
    +        if not self._outcome.success:
    +            result = self._outcome.result
    +            if result is not None and result.failfast:
    +                raise _ShouldStop
    +        elif self._outcome.expectedFailure:
    +            # If the test is expecting a failure, we really want to
    +            # stop now and register the expected failure.
    +            raise _ShouldStop
    +    finally:
    +        self._subtest = parent
    +
    + +
    +
    + +
    + + +
    +
    +

    def tearDown(

    self)

    +
    + + + + +
    + +
    +
    def tearDown(self):
    +    # Delete temporary .git file
    +    sub.call(["rm", "-rf", ".git"])
    +
    + +
    +
    - edge_list = [('Marcela', 'file7.md'), ('Marcela', 'file6.md'), - ('Billy G', 'file4.md'), ('Billy G', 'file5.md'), ('Billy G', 'file6.md'), - ('Jenna', 'file3.md'), ('Jenna', 'file5.md'), - ('Randy', 'file1.md'), ('Randy', 'file2.md'), ('Randy', 'file3.md'), ('Randy', 'file4.md'),] +
    + + +
    +
    +

    def test_domain(

    self)

    +
    + - for n1, n2 in edge_list: - self.assertIn('author', aut_file.edge[n1][n2][0]) - self.assertIn('hash', aut_file.edge[n1][n2][0]) - self.assertNotIn('date', aut_file.edge[n1][n2][0]) - self.assertEqual(len(aut_file.edge[n1][n2]), 1) - self.assertEqual(len(aut_file.edge[n1][n2][0]), 2) + + +

    Is domain being generated correctly?

    +
    + +
    +
    def test_domain(self):
    +    """Is domain being generated correctly?"""
    +    self.assertEqual(self.my_log["7965e62"]["domain"],"gmail")
    +    self.assertEqual(self.my_log["6cd4bbf"]["domain"],"gmail")
    +    self.assertEqual(self.my_log["ee2c408"]["domain"],"gmail")
    +    self.assertEqual(self.my_log["b3a4bac"]["domain"],"gmail")
    +
    - def test_author_file_weighted(self): - weighted = self.my_log.network(type="author/file/weighted") +
    +
    - auth_list = ['Marcela', 'Billy G', 'Jenna', 'Randy'] - for a in auth_list: - self.assertIn('id', weighted.node[a]) - self.assertIn('type', weighted.node[a]) - self.assertEqual(weighted.node[a]['type'], 'author') - self.assertIn('records', weighted.node[a]) - self.assertIn('email', weighted.node[a]) - self.assertIn('hash', weighted.node[a]) - self.assertIn('fedits', weighted.node[a]) - self.assertNotIn('weight', weighted.node[a]) - self.assertNotIn('date', weighted.node[a]) +
    + + +
    +
    +

    def test_utc_date(

    self)

    +
    + - file_list = ['file1.md', 'file2.md', 'file3.md', 'file4.md', 'file5.md', 'file6.md', 'file7.md'] - for f in file_list: - self.assertIn('id', weighted.node[f]) - self.assertIn('type', weighted.node[f]) - self.assertEqual(weighted.node[f]['type'], 'files') - self.assertIn('records', weighted.node[f]) - self.assertIn('hash', weighted.node[f]) - self.assertIn('date', weighted.node[f]) - self.assertNotIn('email', weighted.node[f]) - self.assertNotIn('fedits', weighted.node[f]) - self.assertNotIn('weight', weighted.node[f]) + + +

    Is utc_date being generated correctly?

    +
    + +
    +
    def test_utc_date(self):
    +    """Is utc_date being generated correctly?"""
    +    self.assertEqual(self.my_log["7965e62"]["utc_date"],"2016-05-26")
    +    self.assertEqual(self.my_log["6cd4bbf"]["utc_date"],"2016-05-25")
    +    self.assertEqual(self.my_log["ee2c408"]["utc_date"],"2016-05-23")
    +    self.assertEqual(self.my_log["b3a4bac"]["utc_date"],"2016-05-20")
    +
    - edge_list = [('Marcela', 'file7.md'), ('Marcela', 'file6.md'), - ('Billy G', 'file4.md'), ('Billy G', 'file5.md'), ('Billy G', 'file6.md'), - ('Jenna', 'file3.md'), ('Jenna', 'file5.md'), - ('Randy', 'file1.md'), ('Randy', 'file2.md'), ('Randy', 'file3.md'), ('Randy', 'file4.md'), ] +
    +
    - for n1, n2 in edge_list: - self.assertIn('author', weighted.edge[n1][n2][0]) - self.assertIn('hash', weighted.edge[n1][n2][0]) - self.assertIn('date', weighted.edge[n1][n2][0]) - self.assertIn('weight', weighted.edge[n1][n2][0]) - self.assertEqual(len(weighted.edge[n1][n2]), 1) - self.assertEqual(len(weighted.edge[n1][n2][0]), 4) +
    + + +
    +
    +

    def test_utc_datetime(

    self)

    +
    + - def test_error(self): - with self.assertRaisesRegex(InputError, 'nonsense is not a valid network preset.'): - self.my_log.network(type="nonsense") + + +

    Is utc_datetime being generated correctly?

    +
    + +
    +
    def test_utc_datetime(self):
    +    """Is utc_datetime being generated correctly?"""
    +    self.assertEqual(self.my_log["7965e62"]["utc_datetime"],"2016-05-26 15:21:03")
    +    self.assertEqual(self.my_log["6cd4bbf"]["utc_datetime"],"2016-05-25 05:12:48")
    +    self.assertEqual(self.my_log["ee2c408"]["utc_datetime"],"2016-05-23 06:45:25")
    +    self.assertEqual(self.my_log["b3a4bac"]["utc_datetime"],"2016-05-20 13:19:20")
    +
    - def tearDown(self): - # Delete temporary .git file - sub.call(["rm", "-rf", ".git"]) +
    +
    +
    + +

    Methods

    + +
    +
    +

    def setUpClass(

    cls)

    +
    + -if __name__ == '__main__': - unittest.main(buffer=True) + + +

    Hook method for setting up class fixture before running tests in the class.

    +
    + +
    +
    @classmethod
    +def setUpClass(cls):
    +    "Hook method for setting up class fixture before running tests in the class."
     
    +
    - +
    + + +
    +
    +

    def tearDownClass(

    cls)

    +
    + -
    + + +

    Hook method for deconstructing the class fixture after running all tests in the class.

    +
    + +
    +
    @classmethod
    +def tearDownClass(cls):
    +    "Hook method for deconstructing the class fixture after running all tests in the class."
    +
    +
    +
    -

    Classes

    +
    + +
    +

    class DescribeTests

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -3001,12 +5412,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -3016,45 +5426,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -3074,14 +5460,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -3095,8 +5481,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -3107,7 +5493,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -3118,27 +5504,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -3189,10 +5578,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -3467,19 +5854,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -3501,14 +5888,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -3524,8 +5911,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -3536,7 +5923,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -3550,15 +5937,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -3567,13 +5955,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -4009,7 +6399,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -4142,7 +6531,6 @@

    Static methods

    -

    Hook method for deconstructing the test fixture after testing it.

    @@ -4484,31 +6872,6 @@

    Methods

    class GetTagsTests

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -4522,8 +6885,8 @@

    Methods

    tags = my_log.get_tags() - self.assertListEqual(tags, ["hash", "author", "email", "date", "mode", "merge", "summary", - "fedits", "inserts", "deletes", "message", "files", "changes"]) + self.assertListEqual(tags, ["hash", "author", "email", "domain", "date", "utc_date", "utc_datetime", "mode", "merge", + "summary", "fedits", "inserts", "deletes", "message", "files", "changes"]) # Delete temporary .git file sub.call(["rm", "-rf", ".git"]) @@ -5563,12 +7926,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -5578,45 +7940,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -5636,14 +7974,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -5657,8 +7995,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -5669,7 +8007,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -5680,27 +8018,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -5751,10 +8092,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -6029,19 +8368,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -6063,14 +8402,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -6086,8 +8425,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -6098,7 +8437,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -6112,15 +8451,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -6129,13 +8469,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -6734,8 +9076,8 @@

    Static methods

    path = os.getcwd() my_log = gitnet.get_log(path) tags = my_log.get_tags() - self.assertListEqual(tags, ["hash", "author", "email", "date", "mode", "merge", "summary", - "fedits", "inserts", "deletes", "message", "files", "changes"]) + self.assertListEqual(tags, ["hash", "author", "email", "domain", "date", "utc_date", "utc_datetime", "mode", "merge", + "summary", "fedits", "inserts", "deletes", "message", "files", "changes"]) # Delete temporary .git file sub.call(["rm", "-rf", ".git"])
    @@ -6799,31 +9141,6 @@

    Methods

    class IgnoreTests

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -7901,12 +10218,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -7916,45 +10232,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -7974,14 +10266,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -7995,8 +10287,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -8007,7 +10299,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -8018,27 +10310,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -8089,10 +10384,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -8367,19 +10660,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -8401,14 +10694,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -8424,8 +10717,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -8436,7 +10729,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -8450,15 +10743,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -8467,13 +10761,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -8909,7 +11205,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -9044,7 +11339,6 @@

    Static methods

    -

    Hook method for deconstructing the test fixture after testing it.

    @@ -9194,31 +11488,6 @@

    Methods

    class NetworkTests

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -10421,12 +12690,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -10436,45 +12704,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -10494,14 +12738,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -10515,8 +12759,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -10527,7 +12771,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -10538,27 +12782,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -10609,10 +12856,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -10887,19 +13132,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -10921,14 +13166,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -10944,8 +13189,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -10956,7 +13201,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -10970,15 +13215,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -10987,13 +13233,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -11429,7 +13677,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -11563,7 +13810,6 @@

    Static methods

    -

    Hook method for deconstructing the test fixture after testing it.

    diff --git a/docs/gitnet/gitnet_tests/test_get.m.html b/docs/gitnet/gitnet_tests/test_get.m.html index 3e25819..b00814c 100644 --- a/docs/gitnet/gitnet_tests/test_get.m.html +++ b/docs/gitnet/gitnet_tests/test_get.m.html @@ -1076,7 +1076,6 @@

    Index

  • assertNotIn
  • assertNotIsInstance
  • assertNotRegex
  • -
  • assertNotRegexpMatches
  • assertRaises
  • assertRaisesRegex
  • assertRaisesRegexp
  • @@ -1151,7 +1150,6 @@

    Index

  • assertNotIn
  • assertNotIsInstance
  • assertNotRegex
  • -
  • assertNotRegexpMatches
  • assertRaises
  • assertRaisesRegex
  • assertRaisesRegexp
  • @@ -1227,7 +1225,6 @@

    Index

  • assertNotIn
  • assertNotIsInstance
  • assertNotRegex
  • -
  • assertNotRegexpMatches
  • assertRaises
  • assertRaisesRegex
  • assertRaisesRegexp
  • @@ -1381,20 +1378,19 @@

    gitnet.gitnet_tests.test_get module< self.assertEqual(len(self.nx_log.vector("errors")), 0) def test_big_tsv(self): - tabs = self.nx_log.tsv() - for hsh in self.nx_log: - self.assertTrue(hsh in tabs) + tabs = self.nx_log.tsv("nx_test.tsv") self.nx_log.tsv(fname="nx_test.tsv") f = open("nx_test.tsv", "r") nx_lines = f.readlines() self.assertEqual(len(nx_lines), 4882) - self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildatemodemergesummaryfedits" + self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildomaindateutc_dateutc_datetimemodemergesummaryfedits" "insertsdeletesmessagefileschanges") f.close() - sub.call(["rm", "nx_test.tsv"]) + sub.call(["rm", "-rf", "nx_test.tsv"]) def tearDown(self): sub.call(["rm", "-rf", ".git"]) + sub.call(["rm", "-rf", "nx_test.tsv"]) class TestGetError(unittest.TestCase): @@ -1441,31 +1437,6 @@

    Classes

    class TestBigGit

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -1482,20 +1453,19 @@

    Classes

    self.assertEqual(len(self.nx_log.vector("errors")), 0) def test_big_tsv(self): - tabs = self.nx_log.tsv() - for hsh in self.nx_log: - self.assertTrue(hsh in tabs) + tabs = self.nx_log.tsv("nx_test.tsv") self.nx_log.tsv(fname="nx_test.tsv") f = open("nx_test.tsv", "r") nx_lines = f.readlines() self.assertEqual(len(nx_lines), 4882) - self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildatemodemergesummaryfedits" + self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildomaindateutc_dateutc_datetimemodemergesummaryfedits" "insertsdeletesmessagefileschanges") f.close() - sub.call(["rm", "nx_test.tsv"]) + sub.call(["rm", "-rf", "nx_test.tsv"]) def tearDown(self): sub.call(["rm", "-rf", ".git"]) + sub.call(["rm", "-rf", "nx_test.tsv"])
    @@ -2532,12 +2502,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -2547,45 +2516,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -2605,14 +2550,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -2626,8 +2571,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -2638,7 +2583,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -2649,27 +2594,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -2720,10 +2668,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -2998,19 +2944,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -3032,14 +2978,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -3055,8 +3001,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -3067,7 +3013,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -3081,15 +3027,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -3098,13 +3045,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -3540,7 +3489,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -3673,12 +3621,12 @@

    Static methods

    -

    Hook method for deconstructing the test fixture after testing it.

    def tearDown(self):
         sub.call(["rm", "-rf", ".git"])
    +    sub.call(["rm", "-rf", "nx_test.tsv"])
     
    @@ -3699,17 +3647,15 @@

    Static methods

    def test_big_tsv(self):
    -    tabs = self.nx_log.tsv()
    -    for hsh in self.nx_log:
    -        self.assertTrue(hsh in tabs)
    +    tabs = self.nx_log.tsv("nx_test.tsv")
         self.nx_log.tsv(fname="nx_test.tsv")
         f = open("nx_test.tsv", "r")
         nx_lines = f.readlines()
         self.assertEqual(len(nx_lines), 4882)
    -    self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildatemodemergesummaryfedits"
    +    self.assertEqual(re.sub('[\s+]', '', nx_lines[0]), "hashauthoremaildomaindateutc_dateutc_datetimemodemergesummaryfedits"
                                                            "insertsdeletesmessagefileschanges")
         f.close()
    -    sub.call(["rm", "nx_test.tsv"])
    +    sub.call(["rm", "-rf", "nx_test.tsv"])
     
    @@ -3793,31 +3739,6 @@

    Methods

    class TestGetError

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -4883,12 +4804,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -4898,45 +4818,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -4956,14 +4852,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -4977,8 +4873,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -4989,7 +4885,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -5000,27 +4896,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -5071,10 +4970,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -5349,19 +5246,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -5383,14 +5280,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -5406,8 +5303,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -5418,7 +5315,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -5432,15 +5329,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -5449,13 +5347,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -5891,7 +5791,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -6024,7 +5923,6 @@

    Static methods

    -

    Hook method for deconstructing the test fixture after testing it.

    @@ -6158,31 +6056,6 @@

    Methods

    class TestGetLog

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -7277,12 +7150,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -7292,45 +7164,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -7350,14 +7198,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -7371,8 +7219,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -7383,7 +7231,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -7394,27 +7242,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -7465,10 +7316,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -7743,19 +7592,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -7777,14 +7626,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -7800,8 +7649,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -7812,7 +7661,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -7826,15 +7675,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -7843,13 +7693,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -8285,7 +8137,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -8419,7 +8270,6 @@

    Static methods

    -

    Hook method for deconstructing the test fixture after testing it.

    diff --git a/docs/gitnet/gitnet_tests/test_helpers.m.html b/docs/gitnet/gitnet_tests/test_helpers.m.html index 405d797..a058ac6 100644 --- a/docs/gitnet/gitnet_tests/test_helpers.m.html +++ b/docs/gitnet/gitnet_tests/test_helpers.m.html @@ -1076,7 +1076,6 @@

    Index

  • assertNotIn
  • assertNotIsInstance
  • assertNotRegex
  • -
  • assertNotRegexpMatches
  • assertRaises
  • assertRaisesRegex
  • assertRaisesRegexp
  • @@ -1151,7 +1150,6 @@

    Index

  • assertNotIn
  • assertNotIsInstance
  • assertNotRegex
  • -
  • assertNotRegexpMatches
  • assertRaises
  • assertRaisesRegex
  • assertRaisesRegexp
  • @@ -1226,7 +1224,6 @@

    Index

  • assertNotIn
  • assertNotIsInstance
  • assertNotRegex
  • -
  • assertNotRegexpMatches
  • assertRaises
  • assertRaisesRegex
  • assertRaisesRegexp
  • @@ -1306,7 +1303,6 @@

    Index

  • assertNotIn
  • assertNotIsInstance
  • assertNotRegex
  • -
  • assertNotRegexpMatches
  • assertRaises
  • assertRaisesRegex
  • assertRaisesRegexp
  • @@ -1345,6 +1341,81 @@

    Index

  • tearDownClass
+ +
  • + TestAnnotateHelpers + + + +
  • TestNetAttr @@ -1382,7 +1453,6 @@

    Index

  • assertNotIn
  • assertNotIsInstance
  • assertNotRegex
  • -
  • assertNotRegexpMatches
  • assertRaises
  • assertRaisesRegex
  • assertRaisesRegexp
  • @@ -1782,6 +1852,42 @@

    gitnet.gitnet_tests.test_helpers mod self.assertEqual(res, "lightgrey") +class TestAnnotateHelpers(unittest.TestCase): + + def test_make_utc_date(self): + """Is the function converting the string properly?""" + utc = helpers.make_utc_date({"date":"Mon Jul 22 11:40:03 2013 -0600"}) + self.assertEqual(utc, "2013-07-22") + utc = helpers.make_utc_date({"date":"Sat Apr 16 22:29:50 2016 -0200"}) + self.assertEqual(utc, "2016-04-17") + utc = helpers.make_utc_date({"date":"Fri Oct 5 12:20:15 2012 +0200"}) + self.assertEqual(utc, "2012-10-05") + utc = helpers.make_utc_date({"not":"Fri Oct 5 12:20:15 2012 +0200"}) + self.assertEqual(utc, None) + + def test_make_utc_datetime(self): + """Is the function converting the string properly?""" + utc = helpers.make_utc_datetime({"date":"Mon Jul 22 11:40:03 2013 -0600"}) + self.assertEqual(utc, "2013-07-22 17:40:03") + utc = helpers.make_utc_datetime({"date":"Sat Apr 16 22:29:50 2016 -0200"}) + self.assertEqual(utc, "2016-04-17 00:29:50") + utc = helpers.make_utc_datetime({"date":"Fri Oct 5 12:20:15 2012 +0200"}) + self.assertEqual(utc, "2012-10-05 10:20:15") + utc = helpers.make_utc_datetime({"not":"Fri Oct 5 12:20:15 2012 +0200"}) + self.assertEqual(utc, None) + + def test_make_domain(self): + self.assertEqual(helpers.make_domain({"email":"mail@hoolagin.com"}), "hoolagin") + self.assertEqual(helpers.make_domain({"email":"joe@gmail.com"}), "gmail") + self.assertEqual(helpers.make_domain({"email":"afsjkl@gar.net"}), "gar") + self.assertEqual(helpers.make_domain({"email":"linux@cs.uwaterloo.ca"}), "cs.uwaterloo") + self.assertEqual(helpers.make_domain({"notemail":"mail@hoolagin.com"}), None) + self.assertEqual(helpers.make_domain({"email":"mailhoolagin.com"}), None) + self.assertEqual(helpers.make_domain({"email":"mail@hoolagincom"}), None) + self.assertEqual(helpers.make_domain({"email":"mail@.com"}), None) + self.assertEqual(helpers.make_domain({"email":""}), None) + self.assertEqual(helpers.make_domain({"email":None}), None) + if __name__ == '__main__': unittest.main(buffer=True) @@ -1799,31 +1905,6 @@

    Classes

    class DatetimeTests

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -2884,12 +2965,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -2899,45 +2979,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -2957,14 +3013,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -2978,8 +3034,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -2990,7 +3046,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -3001,27 +3057,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -3072,10 +3131,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -3350,19 +3407,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -3384,14 +3441,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -3407,8 +3464,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -3419,7 +3476,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -3433,15 +3490,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -3450,13 +3508,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -3892,7 +3952,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -4024,7 +4083,6 @@

    Static methods

    -

    Hook method for deconstructing the test fixture after testing it.

    @@ -4140,31 +4198,6 @@

    Methods

    class EdgeGenTests

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -5258,12 +5291,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -5273,45 +5305,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -5331,14 +5339,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -5352,8 +5360,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -5364,7 +5372,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -5375,27 +5383,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -5446,10 +5457,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -5724,19 +5733,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -5758,14 +5767,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -5781,8 +5790,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -5793,7 +5802,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -5807,15 +5816,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -5824,13 +5834,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -6266,7 +6278,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -6402,7 +6413,6 @@

    Static methods

    -

    Hook method for deconstructing the test fixture after testing it.

    @@ -6537,31 +6547,6 @@

    Methods

    class FilterTests

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -7731,12 +7716,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -7746,45 +7730,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -7804,14 +7764,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -7825,8 +7785,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -7837,7 +7797,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -7848,27 +7808,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -7919,10 +7882,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -8197,19 +8158,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -8231,14 +8192,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -8254,8 +8215,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -8266,7 +8227,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -8280,15 +8241,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -8297,13 +8259,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -8739,7 +8703,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -9175,31 +9138,6 @@

    Methods

    class ListTests

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    @@ -10274,12 +10212,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -10289,45 +10226,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -10347,14 +10260,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -10368,8 +10281,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -10380,7 +10293,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -10391,27 +10304,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -10462,10 +10378,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -10740,19 +10654,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -10774,14 +10688,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -10797,8 +10711,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -10809,7 +10723,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -10823,15 +10737,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -10840,13 +10755,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -11282,7 +11199,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    @@ -11562,101 +11478,47 @@

    Methods

    -

    class TestNetAttr

    +

    class TestAnnotateHelpers

    -

    A class whose instances are single test cases.

    -

    By default, the test code itself should be placed in a method named -'runTest'.

    -

    If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

    -

    Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

    -

    If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

    -

    When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

    - -
    -
    class TestNetAttr(unittest.TestCase):
    -    def setUp(self):
    -        self.a_attr = {'id': 'Alice',
    -                       'type': 'author',
    -                       'email': 'alice@gmail.com'}
    -        self.b_attr = {'id': 'Bobby',
    -                       'type': 'author',
    -                       'email': 'bobby@gmail.com'}
    -        self.f1_attr = {'id': 'f01.py',
    -                        'type': 'files'}
    -        self.f2_attr = {'id': 'f02.cc',
    -                        'type': 'files'}
    -        self.f3_attr = {'id': 'f03.h',
    -                        'type': 'files'}
    -        self.f4_attr = {'id': 'f04.txt',
    -                        'type': 'files'}
    -
    -    def test_basic(self):
    -        """Ensure the function returns a string"""
    -        res = helpers.node_colours(self.a_attr)
    -        self.assertIsInstance(res, str)
    -
    -    def test_no_type(self):
    -        """Are nodes with no type assigned lightgrey?"""
    -        notype = {'id': 'mystery',
    -                  'email': 'abc@alphabet.com'}
    -        res = helpers.node_colours(notype)
    -        self.assertEqual(res, "lightgrey")
    -
    -    def test_authors(self):
    -        """Are authors assigned the correct colour?"""
    -        a_res = helpers.node_colours(self.a_attr)
    -        b_res = helpers.node_colours(self.b_attr)
    -
    -        self.assertEqual(a_res, "dodgerblue")
    -        self.assertEqual(b_res, "dodgerblue")
    -
    -    def test_files(self):
    -        """Do files of the types .py, .cc, .h, etc give the correct colours?"""
    -        # Setting up results
    -        res1 = helpers.node_colours(self.f1_attr)
    -        res2 = helpers.node_colours(self.f2_attr)
    -        res3 = helpers.node_colours(self.f3_attr)
    -        res4 = helpers.node_colours(self.f4_attr)
    -
    -        self.assertEqual(res1, "tomato")
    -        self.assertEqual(res2, "gold")
    -        self.assertEqual(res3, "goldenrod")
    -        self.assertEqual(res4, "lightgrey")
    -
    -    def test_files_noid(self):
    -        """Are file nodes with no id assigned lightgrey?"""
    -        noid = {'type': 'files'}
    -        res = helpers.node_colours(noid)
    +  
    +  
    +
    class TestAnnotateHelpers(unittest.TestCase):
     
    -        self.assertEqual(res, "lightgrey")
    +    def test_make_utc_date(self):
    +        """Is the function converting the string properly?"""
    +        utc = helpers.make_utc_date({"date":"Mon Jul 22 11:40:03 2013 -0600"})
    +        self.assertEqual(utc, "2013-07-22")
    +        utc = helpers.make_utc_date({"date":"Sat Apr 16 22:29:50 2016 -0200"})
    +        self.assertEqual(utc, "2016-04-17")
    +        utc = helpers.make_utc_date({"date":"Fri Oct 5 12:20:15 2012 +0200"})
    +        self.assertEqual(utc, "2012-10-05")
    +        utc = helpers.make_utc_date({"not":"Fri Oct 5 12:20:15 2012 +0200"})
    +        self.assertEqual(utc, None)
     
    -    def test_not_aorf(self):
    -        """Are nodes whose type is neither files nor author assigned lightgrey?"""
    -        fnora = {'id': 'Uwaterloo',
    -                 'type': 'university'}
    -        res = helpers.node_colours(fnora)
    +    def test_make_utc_datetime(self):
    +        """Is the function converting the string properly?"""
    +        utc = helpers.make_utc_datetime({"date":"Mon Jul 22 11:40:03 2013 -0600"})
    +        self.assertEqual(utc, "2013-07-22 17:40:03")
    +        utc = helpers.make_utc_datetime({"date":"Sat Apr 16 22:29:50 2016 -0200"})
    +        self.assertEqual(utc, "2016-04-17 00:29:50")
    +        utc = helpers.make_utc_datetime({"date":"Fri Oct 5 12:20:15 2012 +0200"})
    +        self.assertEqual(utc, "2012-10-05 10:20:15")
    +        utc = helpers.make_utc_datetime({"not":"Fri Oct 5 12:20:15 2012 +0200"})
    +        self.assertEqual(utc, None)
     
    -        self.assertEqual(res, "lightgrey")
    +    def test_make_domain(self):
    +        self.assertEqual(helpers.make_domain({"email":"mail@hoolagin.com"}), "hoolagin")
    +        self.assertEqual(helpers.make_domain({"email":"joe@gmail.com"}), "gmail")
    +        self.assertEqual(helpers.make_domain({"email":"afsjkl@gar.net"}), "gar")
    +        self.assertEqual(helpers.make_domain({"email":"linux@cs.uwaterloo.ca"}), "cs.uwaterloo")
    +        self.assertEqual(helpers.make_domain({"notemail":"mail@hoolagin.com"}), None)
    +        self.assertEqual(helpers.make_domain({"email":"mailhoolagin.com"}), None)
    +        self.assertEqual(helpers.make_domain({"email":"mail@hoolagincom"}), None)
    +        self.assertEqual(helpers.make_domain({"email":"mail@.com"}), None)
    +        self.assertEqual(helpers.make_domain({"email":""}), None)
    +        self.assertEqual(helpers.make_domain({"email":None}), None)
     
    @@ -11666,13 +11528,13 @@

    Methods

    Ancestors (in MRO)

    Class variables

    -

    var failureException

    +

    var failureException

    @@ -11682,7 +11544,7 @@

    Class variables

    -

    var longMessage

    +

    var longMessage

    @@ -11692,7 +11554,7 @@

    Class variables

    -

    var maxDiff

    +

    var maxDiff

    @@ -11704,7 +11566,7 @@

    Class variables

    Static methods

    -
    +

    def __init__(

    self, methodName='runTest')

    @@ -11715,8 +11577,8 @@

    Static methods

    method when executed. Raises a ValueError if the instance does not have a method with the specified name.

    - -
    + +
    def __init__(self, methodName='runTest'):
         """Create an instance of the class that will use the named test
            method when executed. Raises a ValueError if the instance does
    @@ -11756,7 +11618,7 @@ 

    Static methods

    -
    +

    def addCleanup(

    self, function, *args, **kwargs)

    @@ -11768,8 +11630,8 @@

    Static methods

    called after tearDown on test failure or success.

    Cleanup items are called even if setUp fails (unlike tearDown).

    - -
    + +
    def addCleanup(self, function, *args, **kwargs):
         """Add a function, with arguments, to be called when the test is
         completed. Functions added are called on a LIFO basis and are
    @@ -11785,7 +11647,7 @@ 

    Static methods

    -
    +

    def addTypeEqualityFunc(

    self, typeobj, function)

    @@ -11802,8 +11664,8 @@

    Static methods

    msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.

    - -
    + +
    def addTypeEqualityFunc(self, typeobj, function):
         """Add a type specific assertEqual style function to compare a type.
         This method is for use by TestCase subclasses that need to register
    @@ -11825,7 +11687,7 @@ 

    Static methods

    -
    +

    def assertAlmostEqual(

    self, first, second, places=None, msg=None, delta=None)

    @@ -11841,8 +11703,8 @@

    Static methods

    If the two objects compare equal then they will automatically compare almost equal.

    - -
    + +
    def assertAlmostEqual(self, first, second, places=None, msg=None,
                           delta=None):
         """Fail if the two objects are unequal as determined by their
    @@ -11884,7 +11746,7 @@ 

    Static methods

    -
    +

    def assertAlmostEquals(

    *args, **kwargs)

    @@ -11892,8 +11754,8 @@

    Static methods

    - -
    + +
    def deprecated_func(*args, **kwargs):
         warnings.warn(
             'Please use {0} instead.'.format(original_func.__name__),
    @@ -11908,7 +11770,7 @@ 

    Static methods

    -
    +

    def assertCountEqual(

    self, first, second, msg=None)

    @@ -11927,8 +11789,8 @@

    Static methods

    - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

    - -
    + +
    def assertCountEqual(self, first, second, msg=None):
         """An unordered sequence comparison asserting that the same elements,
         regardless of order.  If the same element occurs more than once,
    @@ -11966,7 +11828,7 @@ 

    Static methods

    -
    +

    def assertDictContainsSubset(

    self, subset, dictionary, msg=None)

    @@ -11975,8 +11837,8 @@

    Static methods

    Checks whether dictionary is a superset of subset.

    - -
    + +
    def assertDictContainsSubset(self, subset, dictionary, msg=None):
         """Checks whether dictionary is a superset of subset."""
         warnings.warn('assertDictContainsSubset is deprecated',
    @@ -12010,7 +11872,7 @@ 

    Static methods

    -
    +

    def assertDictEqual(

    self, d1, d2, msg=None)

    @@ -12018,8 +11880,8 @@

    Static methods

    - -
    + +
    def assertDictEqual(self, d1, d2, msg=None):
         self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
         self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
    @@ -12039,7 +11901,7 @@ 

    Static methods

    -
    +

    def assertEqual(

    self, first, second, msg=None)

    @@ -12049,8 +11911,8 @@

    Static methods

    Fail if the two objects are unequal as determined by the '==' operator.

    - -
    + +
    def assertEqual(self, first, second, msg=None):
         """Fail if the two objects are unequal as determined by the '=='
            operator.
    @@ -12066,7 +11928,7 @@ 

    Static methods

    -
    +

    def assertEquals(

    *args, **kwargs)

    @@ -12074,8 +11936,8 @@

    Static methods

    - -
    + +
    def deprecated_func(*args, **kwargs):
         warnings.warn(
             'Please use {0} instead.'.format(original_func.__name__),
    @@ -12090,7 +11952,7 @@ 

    Static methods

    -
    +

    def assertFalse(

    self, expr, msg=None)

    @@ -12099,8 +11961,8 @@

    Static methods

    Check that the expression is false.

    - -
    + +
    def assertFalse(self, expr, msg=None):
         """Check that the expression is false."""
         if expr:
    @@ -12115,7 +11977,7 @@ 

    Static methods

    -
    +

    def assertGreater(

    self, a, b, msg=None)

    @@ -12124,8 +11986,8 @@

    Static methods

    Just like self.assertTrue(a > b), but with a nicer default message.

    - -
    + +
    def assertGreater(self, a, b, msg=None):
         """Just like self.assertTrue(a > b), but with a nicer default message."""
         if not a > b:
    @@ -12140,7 +12002,7 @@ 

    Static methods

    -
    +

    def assertGreaterEqual(

    self, a, b, msg=None)

    @@ -12149,8 +12011,8 @@

    Static methods

    Just like self.assertTrue(a >= b), but with a nicer default message.

    - -
    + +
    def assertGreaterEqual(self, a, b, msg=None):
         """Just like self.assertTrue(a >= b), but with a nicer default message."""
         if not a >= b:
    @@ -12165,7 +12027,7 @@ 

    Static methods

    -
    +

    def assertIn(

    self, member, container, msg=None)

    @@ -12174,8 +12036,8 @@

    Static methods

    Just like self.assertTrue(a in b), but with a nicer default message.

    - -
    + +
    def assertIn(self, member, container, msg=None):
         """Just like self.assertTrue(a in b), but with a nicer default message."""
         if member not in container:
    @@ -12191,7 +12053,7 @@ 

    Static methods

    -
    +

    def assertIs(

    self, expr1, expr2, msg=None)

    @@ -12200,8 +12062,8 @@

    Static methods

    Just like self.assertTrue(a is b), but with a nicer default message.

    - -
    + +
    def assertIs(self, expr1, expr2, msg=None):
         """Just like self.assertTrue(a is b), but with a nicer default message."""
         if expr1 is not expr2:
    @@ -12217,7 +12079,7 @@ 

    Static methods

    -
    +

    def assertIsInstance(

    self, obj, cls, msg=None)

    @@ -12227,8 +12089,8 @@

    Static methods

    Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

    - -
    + +
    def assertIsInstance(self, obj, cls, msg=None):
         """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
         default message."""
    @@ -12244,7 +12106,7 @@ 

    Static methods

    -
    +

    def assertIsNone(

    self, obj, msg=None)

    @@ -12253,8 +12115,8 @@

    Static methods

    Same as self.assertTrue(obj is None), with a nicer default message.

    - -
    + +
    def assertIsNone(self, obj, msg=None):
         """Same as self.assertTrue(obj is None), with a nicer default message."""
         if obj is not None:
    @@ -12269,7 +12131,7 @@ 

    Static methods

    -
    +

    def assertIsNot(

    self, expr1, expr2, msg=None)

    @@ -12278,8 +12140,8 @@

    Static methods

    Just like self.assertTrue(a is not b), but with a nicer default message.

    - -
    + +
    def assertIsNot(self, expr1, expr2, msg=None):
         """Just like self.assertTrue(a is not b), but with a nicer default message."""
         if expr1 is expr2:
    @@ -12294,7 +12156,7 @@ 

    Static methods

    -
    +

    def assertIsNotNone(

    self, obj, msg=None)

    @@ -12303,8 +12165,8 @@

    Static methods

    Included for symmetry with assertIsNone.

    - -
    + +
    def assertIsNotNone(self, obj, msg=None):
         """Included for symmetry with assertIsNone."""
         if obj is None:
    @@ -12319,7 +12181,7 @@ 

    Static methods

    -
    +

    def assertLess(

    self, a, b, msg=None)

    @@ -12328,8 +12190,8 @@

    Static methods

    Just like self.assertTrue(a < b), but with a nicer default message.

    - -
    + +
    def assertLess(self, a, b, msg=None):
         """Just like self.assertTrue(a < b), but with a nicer default message."""
         if not a < b:
    @@ -12344,7 +12206,7 @@ 

    Static methods

    -
    +

    def assertLessEqual(

    self, a, b, msg=None)

    @@ -12353,8 +12215,8 @@

    Static methods

    Just like self.assertTrue(a <= b), but with a nicer default message.

    - -
    + +
    def assertLessEqual(self, a, b, msg=None):
         """Just like self.assertTrue(a <= b), but with a nicer default message."""
         if not a <= b:
    @@ -12369,7 +12231,7 @@ 

    Static methods

    -
    +

    def assertListEqual(

    self, list1, list2, msg=None)

    @@ -12383,8 +12245,8 @@

    Static methods

    msg: Optional message to use on failure instead of a list of differences.

    - -
    + +
    def assertListEqual(self, list1, list2, msg=None):
         """A list-specific equality assertion.
         Args:
    @@ -12403,7 +12265,7 @@ 

    Static methods

    -
    +

    def assertLogs(

    self, logger=None, level=None)

    @@ -12427,8 +12289,8 @@

    Static methods

    'ERROR:foo.bar:second message'])
    - -
    + +
    def assertLogs(self, logger=None, level=None):
         """Fail unless a log message of level *level* or higher is emitted
         on *logger_name* or its children.  If omitted, *level* defaults to
    @@ -12456,7 +12318,2386 @@ 

    Static methods

    -
    +
    +

    def assertMultiLineEqual(

    self, first, second, msg=None)

    +
    + + + + +

    Assert that two multi-line strings are equal.

    +
    + +
    +
    def assertMultiLineEqual(self, first, second, msg=None):
    +    """Assert that two multi-line strings are equal."""
    +    self.assertIsInstance(first, str, 'First argument is not a string')
    +    self.assertIsInstance(second, str, 'Second argument is not a string')
    +    if first != second:
    +        # don't use difflib if the strings are too long
    +        if (len(first) > self._diffThreshold or
    +            len(second) > self._diffThreshold):
    +            self._baseAssertEqual(first, second, msg)
    +        firstlines = first.splitlines(keepends=True)
    +        secondlines = second.splitlines(keepends=True)
    +        if len(firstlines) == 1 and first.strip('\r\n') == first:
    +            firstlines = [first + '\n']
    +            secondlines = [second + '\n']
    +        standardMsg = '%s != %s' % _common_shorten_repr(first, second)
    +        diff = '\n' + ''.join(difflib.ndiff(firstlines, secondlines))
    +        standardMsg = self._truncateMessage(standardMsg, diff)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotAlmostEqual(

    self, first, second, places=None, msg=None, delta=None)

    +
    + + + + +

    Fail if the two objects are equal as determined by their +difference rounded to the given number of decimal places +(default 7) and comparing to zero, or by comparing that the +between the two objects is less than the given delta.

    +

    Note that decimal places (from zero) are usually not the same +as significant digits (measured from the most signficant digit).

    +

    Objects that are equal automatically fail.

    +
    + +
    +
    def assertNotAlmostEqual(self, first, second, places=None, msg=None,
    +                         delta=None):
    +    """Fail if the two objects are equal as determined by their
    +       difference rounded to the given number of decimal places
    +       (default 7) and comparing to zero, or by comparing that the
    +       between the two objects is less than the given delta.
    +       Note that decimal places (from zero) are usually not the same
    +       as significant digits (measured from the most signficant digit).
    +       Objects that are equal automatically fail.
    +    """
    +    if delta is not None and places is not None:
    +        raise TypeError("specify delta or places not both")
    +    if delta is not None:
    +        if not (first == second) and abs(first - second) > delta:
    +            return
    +        standardMsg = '%s == %s within %s delta' % (safe_repr(first),
    +                                                    safe_repr(second),
    +                                                    safe_repr(delta))
    +    else:
    +        if places is None:
    +            places = 7
    +        if not (first == second) and round(abs(second-first), places) != 0:
    +            return
    +        standardMsg = '%s == %s within %r places' % (safe_repr(first),
    +                                                     safe_repr(second),
    +                                                     places)
    +    msg = self._formatMessage(msg, standardMsg)
    +    raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotAlmostEquals(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotEqual(

    self, first, second, msg=None)

    +
    + + + + +

    Fail if the two objects are equal as determined by the '!=' +operator.

    +
    + +
    +
    def assertNotEqual(self, first, second, msg=None):
    +    """Fail if the two objects are equal as determined by the '!='
    +       operator.
    +    """
    +    if not first != second:
    +        msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first),
    +                                                      safe_repr(second)))
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotEquals(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotIn(

    self, member, container, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a not in b), but with a nicer default message.

    +
    + +
    +
    def assertNotIn(self, member, container, msg=None):
    +    """Just like self.assertTrue(a not in b), but with a nicer default message."""
    +    if member in container:
    +        standardMsg = '%s unexpectedly found in %s' % (safe_repr(member),
    +                                                    safe_repr(container))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotIsInstance(

    self, obj, cls, msg=None)

    +
    + + + + +

    Included for symmetry with assertIsInstance.

    +
    + +
    +
    def assertNotIsInstance(self, obj, cls, msg=None):
    +    """Included for symmetry with assertIsInstance."""
    +    if isinstance(obj, cls):
    +        standardMsg = '%s is an instance of %r' % (safe_repr(obj), cls)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertNotRegex(

    self, text, unexpected_regex, msg=None)

    +
    + + + + +

    Fail the test if the text matches the regular expression.

    +
    + +
    +
    def assertNotRegex(self, text, unexpected_regex, msg=None):
    +    """Fail the test if the text matches the regular expression."""
    +    if isinstance(unexpected_regex, (str, bytes)):
    +        unexpected_regex = re.compile(unexpected_regex)
    +    match = unexpected_regex.search(text)
    +    if match:
    +        msg = msg or "Regex matched"
    +        msg = '%s: %r matches %r in %r' % (msg,
    +                                           text[match.start():match.end()],
    +                                           unexpected_regex.pattern,
    +                                           text)
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    +
    + + + + +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is +raised, it will not be caught, and the test case will be +deemed to have suffered an error, exactly as for an +unexpected exception.

    +

    If called with callableObj omitted or None, will return a +context object used like this::

    +
     with self.assertRaises(SomeException):
    +     do_something()
    +
    + + +

    An optional keyword argument 'msg' can be provided when assertRaises +is used as a context object.

    +

    The context manager keeps a reference to the exception as +the 'exception' attribute. This allows you to inspect the +exception after the assertion::

    +
    with self.assertRaises(SomeException) as cm:
    +    do_something()
    +the_exception = cm.exception
    +self.assertEqual(the_exception.error_code, 3)
    +
    +
    + +
    +
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
    +       raised, it will not be caught, and the test case will be
    +       deemed to have suffered an error, exactly as for an
    +       unexpected exception.
    +       If called with callableObj omitted or None, will return a
    +       context object used like this::
    +            with self.assertRaises(SomeException):
    +                do_something()
    +       An optional keyword argument 'msg' can be provided when assertRaises
    +       is used as a context object.
    +       The context manager keeps a reference to the exception as
    +       the 'exception' attribute. This allows you to inspect the
    +       exception after the assertion::
    +           with self.assertRaises(SomeException) as cm:
    +               do_something()
    +           the_exception = cm.exception
    +           self.assertEqual(the_exception.error_code, 3)
    +    """
    +    context = _AssertRaisesContext(excClass, self, callableObj)
    +    return context.handle('assertRaises', callableObj, args, kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    +
    + + + + +

    Asserts that the message in a raised exception matches a regex.

    +

    Args: + expected_exception: Exception class expected to be raised. + expected_regex: Regex (re pattern object or string) expected + to be found in error message. + callable_obj: Function to be called. + msg: Optional message used in case of failure. Can only be used + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    +
    + +
    +
    def assertRaisesRegex(self, expected_exception, expected_regex,
    +                      callable_obj=None, *args, **kwargs):
    +    """Asserts that the message in a raised exception matches a regex.
    +    Args:
    +        expected_exception: Exception class expected to be raised.
    +        expected_regex: Regex (re pattern object or string) expected
    +                to be found in error message.
    +        callable_obj: Function to be called.
    +        msg: Optional message used in case of failure. Can only be used
    +                when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
    +    """
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRaisesRegexp(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRegex(

    self, text, expected_regex, msg=None)

    +
    + + + + +

    Fail the test unless the text matches the regular expression.

    +
    + +
    +
    def assertRegex(self, text, expected_regex, msg=None):
    +    """Fail the test unless the text matches the regular expression."""
    +    if isinstance(expected_regex, (str, bytes)):
    +        assert expected_regex, "expected_regex must not be empty."
    +        expected_regex = re.compile(expected_regex)
    +    if not expected_regex.search(text):
    +        msg = msg or "Regex didn't match"
    +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertRegexpMatches(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertSequenceEqual(

    self, seq1, seq2, msg=None, seq_type=None)

    +
    + + + + +

    An equality assertion for ordered sequences (like lists and tuples).

    +

    For the purposes of this function, a valid ordered sequence type is one +which can be indexed, has a length, and has an equality operator.

    +

    Args: + seq1: The first sequence to compare. + seq2: The second sequence to compare. + seq_type: The expected datatype of the sequences, or None if no + datatype should be enforced. + msg: Optional message to use on failure instead of a list of + differences.

    +
    + +
    +
    def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
    +    """An equality assertion for ordered sequences (like lists and tuples).
    +    For the purposes of this function, a valid ordered sequence type is one
    +    which can be indexed, has a length, and has an equality operator.
    +    Args:
    +        seq1: The first sequence to compare.
    +        seq2: The second sequence to compare.
    +        seq_type: The expected datatype of the sequences, or None if no
    +                datatype should be enforced.
    +        msg: Optional message to use on failure instead of a list of
    +                differences.
    +    """
    +    if seq_type is not None:
    +        seq_type_name = seq_type.__name__
    +        if not isinstance(seq1, seq_type):
    +            raise self.failureException('First sequence is not a %s: %s'
    +                                    % (seq_type_name, safe_repr(seq1)))
    +        if not isinstance(seq2, seq_type):
    +            raise self.failureException('Second sequence is not a %s: %s'
    +                                    % (seq_type_name, safe_repr(seq2)))
    +    else:
    +        seq_type_name = "sequence"
    +    differing = None
    +    try:
    +        len1 = len(seq1)
    +    except (TypeError, NotImplementedError):
    +        differing = 'First %s has no length.    Non-sequence?' % (
    +                seq_type_name)
    +    if differing is None:
    +        try:
    +            len2 = len(seq2)
    +        except (TypeError, NotImplementedError):
    +            differing = 'Second %s has no length.    Non-sequence?' % (
    +                    seq_type_name)
    +    if differing is None:
    +        if seq1 == seq2:
    +            return
    +        differing = '%ss differ: %s != %s\n' % (
    +                (seq_type_name.capitalize(),) +
    +                _common_shorten_repr(seq1, seq2))
    +        for i in range(min(len1, len2)):
    +            try:
    +                item1 = seq1[i]
    +            except (TypeError, IndexError, NotImplementedError):
    +                differing += ('\nUnable to index element %d of first %s\n' %
    +                             (i, seq_type_name))
    +                break
    +            try:
    +                item2 = seq2[i]
    +            except (TypeError, IndexError, NotImplementedError):
    +                differing += ('\nUnable to index element %d of second %s\n' %
    +                             (i, seq_type_name))
    +                break
    +            if item1 != item2:
    +                differing += ('\nFirst differing element %d:\n%s\n%s\n' %
    +                             (i, item1, item2))
    +                break
    +        else:
    +            if (len1 == len2 and seq_type is None and
    +                type(seq1) != type(seq2)):
    +                # The sequences are the same, but have differing types.
    +                return
    +        if len1 > len2:
    +            differing += ('\nFirst %s contains %d additional '
    +                         'elements.\n' % (seq_type_name, len1 - len2))
    +            try:
    +                differing += ('First extra element %d:\n%s\n' %
    +                              (len2, seq1[len2]))
    +            except (TypeError, IndexError, NotImplementedError):
    +                differing += ('Unable to index element %d '
    +                              'of first %s\n' % (len2, seq_type_name))
    +        elif len1 < len2:
    +            differing += ('\nSecond %s contains %d additional '
    +                         'elements.\n' % (seq_type_name, len2 - len1))
    +            try:
    +                differing += ('First extra element %d:\n%s\n' %
    +                              (len1, seq2[len1]))
    +            except (TypeError, IndexError, NotImplementedError):
    +                differing += ('Unable to index element %d '
    +                              'of second %s\n' % (len1, seq_type_name))
    +    standardMsg = differing
    +    diffMsg = '\n' + '\n'.join(
    +        difflib.ndiff(pprint.pformat(seq1).splitlines(),
    +                      pprint.pformat(seq2).splitlines()))
    +    standardMsg = self._truncateMessage(standardMsg, diffMsg)
    +    msg = self._formatMessage(msg, standardMsg)
    +    self.fail(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertSetEqual(

    self, set1, set2, msg=None)

    +
    + + + + +

    A set-specific equality assertion.

    +

    Args: + set1: The first set to compare. + set2: The second set to compare. + msg: Optional message to use on failure instead of a list of + differences.

    +

    assertSetEqual uses ducktyping to support different types of sets, and +is optimized for sets specifically (parameters must support a +difference method).

    +
    + +
    +
    def assertSetEqual(self, set1, set2, msg=None):
    +    """A set-specific equality assertion.
    +    Args:
    +        set1: The first set to compare.
    +        set2: The second set to compare.
    +        msg: Optional message to use on failure instead of a list of
    +                differences.
    +    assertSetEqual uses ducktyping to support different types of sets, and
    +    is optimized for sets specifically (parameters must support a
    +    difference method).
    +    """
    +    try:
    +        difference1 = set1.difference(set2)
    +    except TypeError as e:
    +        self.fail('invalid type when attempting set difference: %s' % e)
    +    except AttributeError as e:
    +        self.fail('first argument does not support set difference: %s' % e)
    +    try:
    +        difference2 = set2.difference(set1)
    +    except TypeError as e:
    +        self.fail('invalid type when attempting set difference: %s' % e)
    +    except AttributeError as e:
    +        self.fail('second argument does not support set difference: %s' % e)
    +    if not (difference1 or difference2):
    +        return
    +    lines = []
    +    if difference1:
    +        lines.append('Items in the first set but not the second:')
    +        for item in difference1:
    +            lines.append(repr(item))
    +    if difference2:
    +        lines.append('Items in the second set but not the first:')
    +        for item in difference2:
    +            lines.append(repr(item))
    +    standardMsg = '\n'.join(lines)
    +    self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertTrue(

    self, expr, msg=None)

    +
    + + + + +

    Check that the expression is true.

    +
    + +
    +
    def assertTrue(self, expr, msg=None):
    +    """Check that the expression is true."""
    +    if not expr:
    +        msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertTupleEqual(

    self, tuple1, tuple2, msg=None)

    +
    + + + + +

    A tuple-specific equality assertion.

    +

    Args: + tuple1: The first tuple to compare. + tuple2: The second tuple to compare. + msg: Optional message to use on failure instead of a list of + differences.

    +
    + +
    +
    def assertTupleEqual(self, tuple1, tuple2, msg=None):
    +    """A tuple-specific equality assertion.
    +    Args:
    +        tuple1: The first tuple to compare.
    +        tuple2: The second tuple to compare.
    +        msg: Optional message to use on failure instead of a list of
    +                differences.
    +    """
    +    self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    +
    + + + + +

    Fail unless a warning of class warnClass is triggered +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is +triggered, it will not be handled: depending on the other +warning filtering rules in effect, it might be silenced, printed +out, or raised as an exception.

    +

    If called with callable_obj omitted or None, will return a +context object used like this::

    +
     with self.assertWarns(SomeWarning):
    +     do_something()
    +
    + + +

    An optional keyword argument 'msg' can be provided when assertWarns +is used as a context object.

    +

    The context manager keeps a reference to the first matching +warning as the 'warning' attribute; similarly, the 'filename' +and 'lineno' attributes give you information about the line +of Python code from which the warning was triggered. +This allows you to inspect the warning after the assertion::

    +
    with self.assertWarns(SomeWarning) as cm:
    +    do_something()
    +the_warning = cm.warning
    +self.assertEqual(the_warning.some_attribute, 147)
    +
    +
    + +
    +
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
    +    """Fail unless a warning of class warnClass is triggered
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
    +       triggered, it will not be handled: depending on the other
    +       warning filtering rules in effect, it might be silenced, printed
    +       out, or raised as an exception.
    +       If called with callable_obj omitted or None, will return a
    +       context object used like this::
    +            with self.assertWarns(SomeWarning):
    +                do_something()
    +       An optional keyword argument 'msg' can be provided when assertWarns
    +       is used as a context object.
    +       The context manager keeps a reference to the first matching
    +       warning as the 'warning' attribute; similarly, the 'filename'
    +       and 'lineno' attributes give you information about the line
    +       of Python code from which the warning was triggered.
    +       This allows you to inspect the warning after the assertion::
    +           with self.assertWarns(SomeWarning) as cm:
    +               do_something()
    +           the_warning = cm.warning
    +           self.assertEqual(the_warning.some_attribute, 147)
    +    """
    +    context = _AssertWarnsContext(expected_warning, self, callable_obj)
    +    return context.handle('assertWarns', callable_obj, args, kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    +
    + + + + +

    Asserts that the message in a triggered warning matches a regexp. +Basic functioning is similar to assertWarns() with the addition +that only warnings whose messages also match the regular expression +are considered successful matches.

    +

    Args: + expected_warning: Warning class expected to be triggered. + expected_regex: Regex (re pattern object or string) expected + to be found in error message. + callable_obj: Function to be called. + msg: Optional message used in case of failure. Can only be used + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    +
    + +
    +
    def assertWarnsRegex(self, expected_warning, expected_regex,
    +                     callable_obj=None, *args, **kwargs):
    +    """Asserts that the message in a triggered warning matches a regexp.
    +    Basic functioning is similar to assertWarns() with the addition
    +    that only warnings whose messages also match the regular expression
    +    are considered successful matches.
    +    Args:
    +        expected_warning: Warning class expected to be triggered.
    +        expected_regex: Regex (re pattern object or string) expected
    +                to be found in error message.
    +        callable_obj: Function to be called.
    +        msg: Optional message used in case of failure. Can only be used
    +                when assertWarnsRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
    +    """
    +    context = _AssertWarnsContext(expected_warning, self, callable_obj,
    +                                  expected_regex)
    +    return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assert_(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def countTestCases(

    self)

    +
    + + + + +
    + +
    +
    def countTestCases(self):
    +    return 1
    +
    + +
    +
    + +
    + + +
    +
    +

    def debug(

    self)

    +
    + + + + +

    Run the test without collecting errors in a TestResult

    +
    + +
    +
    def debug(self):
    +    """Run the test without collecting errors in a TestResult"""
    +    self.setUp()
    +    getattr(self, self._testMethodName)()
    +    self.tearDown()
    +    while self._cleanups:
    +        function, args, kwargs = self._cleanups.pop(-1)
    +        function(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def defaultTestResult(

    self)

    +
    + + + + +
    + +
    +
    def defaultTestResult(self):
    +    return result.TestResult()
    +
    + +
    +
    + +
    + + +
    +
    +

    def doCleanups(

    self)

    +
    + + + + +

    Execute all cleanup functions. Normally called for you after +tearDown.

    +
    + +
    +
    def doCleanups(self):
    +    """Execute all cleanup functions. Normally called for you after
    +    tearDown."""
    +    outcome = self._outcome or _Outcome()
    +    while self._cleanups:
    +        function, args, kwargs = self._cleanups.pop()
    +        with outcome.testPartExecutor(self):
    +            function(*args, **kwargs)
    +    # return this for backwards compatibility
    +    # even though we no longer us it internally
    +    return outcome.success
    +
    + +
    +
    + +
    + + +
    +
    +

    def fail(

    self, msg=None)

    +
    + + + + +

    Fail immediately, with the given message.

    +
    + +
    +
    def fail(self, msg=None):
    +    """Fail immediately, with the given message."""
    +    raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failIf(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failIfAlmostEqual(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failIfEqual(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failUnless(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failUnlessAlmostEqual(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failUnlessEqual(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def failUnlessRaises(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def id(

    self)

    +
    + + + + +
    + +
    +
    def id(self):
    +    return "%s.%s" % (strclass(self.__class__), self._testMethodName)
    +
    + +
    +
    + +
    + + +
    +
    +

    def run(

    self, result=None)

    +
    + + + + +
    + +
    +
    def run(self, result=None):
    +    orig_result = result
    +    if result is None:
    +        result = self.defaultTestResult()
    +        startTestRun = getattr(result, 'startTestRun', None)
    +        if startTestRun is not None:
    +            startTestRun()
    +    result.startTest(self)
    +    testMethod = getattr(self, self._testMethodName)
    +    if (getattr(self.__class__, "__unittest_skip__", False) or
    +        getattr(testMethod, "__unittest_skip__", False)):
    +        # If the class or method was skipped.
    +        try:
    +            skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
    +                        or getattr(testMethod, '__unittest_skip_why__', ''))
    +            self._addSkip(result, self, skip_why)
    +        finally:
    +            result.stopTest(self)
    +        return
    +    expecting_failure_method = getattr(testMethod,
    +                                       "__unittest_expecting_failure__", False)
    +    expecting_failure_class = getattr(self,
    +                                      "__unittest_expecting_failure__", False)
    +    expecting_failure = expecting_failure_class or expecting_failure_method
    +    outcome = _Outcome(result)
    +    try:
    +        self._outcome = outcome
    +        with outcome.testPartExecutor(self):
    +            self.setUp()
    +        if outcome.success:
    +            outcome.expecting_failure = expecting_failure
    +            with outcome.testPartExecutor(self, isTest=True):
    +                testMethod()
    +            outcome.expecting_failure = False
    +            with outcome.testPartExecutor(self):
    +                self.tearDown()
    +        self.doCleanups()
    +        for test, reason in outcome.skipped:
    +            self._addSkip(result, test, reason)
    +        self._feedErrorsToResult(result, outcome.errors)
    +        if outcome.success:
    +            if expecting_failure:
    +                if outcome.expectedFailure:
    +                    self._addExpectedFailure(result, outcome.expectedFailure)
    +                else:
    +                    self._addUnexpectedSuccess(result)
    +            else:
    +                result.addSuccess(self)
    +        return result
    +    finally:
    +        result.stopTest(self)
    +        if orig_result is None:
    +            stopTestRun = getattr(result, 'stopTestRun', None)
    +            if stopTestRun is not None:
    +                stopTestRun()
    +        # explicitly break reference cycles:
    +        # outcome.errors -> frame -> outcome -> outcome.errors
    +        # outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure
    +        outcome.errors.clear()
    +        outcome.expectedFailure = None
    +        # clear the outcome, no more needed
    +        self._outcome = None
    +
    + +
    +
    + +
    + + +
    +
    +

    def setUp(

    self)

    +
    + + + + +

    Hook method for setting up the test fixture before exercising it.

    +
    + +
    +
    def setUp(self):
    +    "Hook method for setting up the test fixture before exercising it."
    +    pass
    +
    + +
    +
    + +
    + + +
    +
    +

    def shortDescription(

    self)

    +
    + + + + +

    Returns a one-line description of the test, or None if no +description has been provided.

    +

    The default implementation of this method returns the first line of +the specified test method's docstring.

    +
    + +
    +
    def shortDescription(self):
    +    """Returns a one-line description of the test, or None if no
    +    description has been provided.
    +    The default implementation of this method returns the first line of
    +    the specified test method's docstring.
    +    """
    +    doc = self._testMethodDoc
    +    return doc and doc.split("\n")[0].strip() or None
    +
    + +
    +
    + +
    + + +
    +
    +

    def skipTest(

    self, reason)

    +
    + + + + +

    Skip this test.

    +
    + +
    +
    def skipTest(self, reason):
    +    """Skip this test."""
    +    raise SkipTest(reason)
    +
    + +
    +
    + +
    + + +
    +
    +

    def subTest(

    *args, **kwds)

    +
    + + + + +

    Return a context manager that will return the enclosed block +of code in a subtest identified by the optional message and +keyword parameters. A failure in the subtest marks the test +case as failed but resumes execution at the end of the enclosed +block, allowing further test code to be executed.

    +
    + +
    +
    @contextlib.contextmanager
    +def subTest(self, msg=None, **params):
    +    """Return a context manager that will return the enclosed block
    +    of code in a subtest identified by the optional message and
    +    keyword parameters.  A failure in the subtest marks the test
    +    case as failed but resumes execution at the end of the enclosed
    +    block, allowing further test code to be executed.
    +    """
    +    if not self._outcome.result_supports_subtests:
    +        yield
    +        return
    +    parent = self._subtest
    +    if parent is None:
    +        params_map = collections.ChainMap(params)
    +    else:
    +        params_map = parent.params.new_child(params)
    +    self._subtest = _SubTest(self, msg, params_map)
    +    try:
    +        with self._outcome.testPartExecutor(self._subtest, isTest=True):
    +            yield
    +        if not self._outcome.success:
    +            result = self._outcome.result
    +            if result is not None and result.failfast:
    +                raise _ShouldStop
    +        elif self._outcome.expectedFailure:
    +            # If the test is expecting a failure, we really want to
    +            # stop now and register the expected failure.
    +            raise _ShouldStop
    +    finally:
    +        self._subtest = parent
    +
    + +
    +
    + +
    + + +
    +
    +

    def tearDown(

    self)

    +
    + + + + +

    Hook method for deconstructing the test fixture after testing it.

    +
    + +
    +
    def tearDown(self):
    +    "Hook method for deconstructing the test fixture after testing it."
    +    pass
    +
    + +
    +
    + +
    + + +
    +
    +

    def test_make_domain(

    self)

    +
    + + + + +
    + +
    +
    def test_make_domain(self):
    +    self.assertEqual(helpers.make_domain({"email":"mail@hoolagin.com"}), "hoolagin")
    +    self.assertEqual(helpers.make_domain({"email":"joe@gmail.com"}), "gmail")
    +    self.assertEqual(helpers.make_domain({"email":"afsjkl@gar.net"}), "gar")
    +    self.assertEqual(helpers.make_domain({"email":"linux@cs.uwaterloo.ca"}), "cs.uwaterloo")
    +    self.assertEqual(helpers.make_domain({"notemail":"mail@hoolagin.com"}), None)
    +    self.assertEqual(helpers.make_domain({"email":"mailhoolagin.com"}), None)
    +    self.assertEqual(helpers.make_domain({"email":"mail@hoolagincom"}), None)
    +    self.assertEqual(helpers.make_domain({"email":"mail@.com"}), None)
    +    self.assertEqual(helpers.make_domain({"email":""}), None)
    +    self.assertEqual(helpers.make_domain({"email":None}), None)
    +
    + +
    +
    + +
    + + +
    +
    +

    def test_make_utc_date(

    self)

    +
    + + + + +

    Is the function converting the string properly?

    +
    + +
    +
    def test_make_utc_date(self):
    +    """Is the function converting the string properly?"""
    +    utc = helpers.make_utc_date({"date":"Mon Jul 22 11:40:03 2013 -0600"})
    +    self.assertEqual(utc, "2013-07-22")
    +    utc = helpers.make_utc_date({"date":"Sat Apr 16 22:29:50 2016 -0200"})
    +    self.assertEqual(utc, "2016-04-17")
    +    utc = helpers.make_utc_date({"date":"Fri Oct 5 12:20:15 2012 +0200"})
    +    self.assertEqual(utc, "2012-10-05")
    +    utc = helpers.make_utc_date({"not":"Fri Oct 5 12:20:15 2012 +0200"})
    +    self.assertEqual(utc, None)
    +
    + +
    +
    + +
    + + +
    +
    +

    def test_make_utc_datetime(

    self)

    +
    + + + + +

    Is the function converting the string properly?

    +
    + +
    +
    def test_make_utc_datetime(self):
    +    """Is the function converting the string properly?"""
    +    utc = helpers.make_utc_datetime({"date":"Mon Jul 22 11:40:03 2013 -0600"})
    +    self.assertEqual(utc, "2013-07-22 17:40:03")
    +    utc = helpers.make_utc_datetime({"date":"Sat Apr 16 22:29:50 2016 -0200"})
    +    self.assertEqual(utc, "2016-04-17 00:29:50")
    +    utc = helpers.make_utc_datetime({"date":"Fri Oct 5 12:20:15 2012 +0200"})
    +    self.assertEqual(utc, "2012-10-05 10:20:15")
    +    utc = helpers.make_utc_datetime({"not":"Fri Oct 5 12:20:15 2012 +0200"})
    +    self.assertEqual(utc, None)
    +
    + +
    +
    + +
    + +

    Methods

    + +
    +
    +

    def setUpClass(

    cls)

    +
    + + + + +

    Hook method for setting up class fixture before running tests in the class.

    +
    + +
    +
    @classmethod
    +def setUpClass(cls):
    +    "Hook method for setting up class fixture before running tests in the class."
    +
    + +
    +
    + +
    + + +
    +
    +

    def tearDownClass(

    cls)

    +
    + + + + +

    Hook method for deconstructing the class fixture after running all tests in the class.

    +
    + +
    +
    @classmethod
    +def tearDownClass(cls):
    +    "Hook method for deconstructing the class fixture after running all tests in the class."
    +
    + +
    +
    + +
    + +
    +
    + +
    +

    class TestNetAttr

    + + +
    + +
    +
    class TestNetAttr(unittest.TestCase):
    +    def setUp(self):
    +        self.a_attr = {'id': 'Alice',
    +                       'type': 'author',
    +                       'email': 'alice@gmail.com'}
    +        self.b_attr = {'id': 'Bobby',
    +                       'type': 'author',
    +                       'email': 'bobby@gmail.com'}
    +        self.f1_attr = {'id': 'f01.py',
    +                        'type': 'files'}
    +        self.f2_attr = {'id': 'f02.cc',
    +                        'type': 'files'}
    +        self.f3_attr = {'id': 'f03.h',
    +                        'type': 'files'}
    +        self.f4_attr = {'id': 'f04.txt',
    +                        'type': 'files'}
    +
    +    def test_basic(self):
    +        """Ensure the function returns a string"""
    +        res = helpers.node_colours(self.a_attr)
    +        self.assertIsInstance(res, str)
    +
    +    def test_no_type(self):
    +        """Are nodes with no type assigned lightgrey?"""
    +        notype = {'id': 'mystery',
    +                  'email': 'abc@alphabet.com'}
    +        res = helpers.node_colours(notype)
    +        self.assertEqual(res, "lightgrey")
    +
    +    def test_authors(self):
    +        """Are authors assigned the correct colour?"""
    +        a_res = helpers.node_colours(self.a_attr)
    +        b_res = helpers.node_colours(self.b_attr)
    +
    +        self.assertEqual(a_res, "dodgerblue")
    +        self.assertEqual(b_res, "dodgerblue")
    +
    +    def test_files(self):
    +        """Do files of the types .py, .cc, .h, etc give the correct colours?"""
    +        # Setting up results
    +        res1 = helpers.node_colours(self.f1_attr)
    +        res2 = helpers.node_colours(self.f2_attr)
    +        res3 = helpers.node_colours(self.f3_attr)
    +        res4 = helpers.node_colours(self.f4_attr)
    +
    +        self.assertEqual(res1, "tomato")
    +        self.assertEqual(res2, "gold")
    +        self.assertEqual(res3, "goldenrod")
    +        self.assertEqual(res4, "lightgrey")
    +
    +    def test_files_noid(self):
    +        """Are file nodes with no id assigned lightgrey?"""
    +        noid = {'type': 'files'}
    +        res = helpers.node_colours(noid)
    +
    +        self.assertEqual(res, "lightgrey")
    +
    +    def test_not_aorf(self):
    +        """Are nodes whose type is neither files nor author assigned lightgrey?"""
    +        fnora = {'id': 'Uwaterloo',
    +                 'type': 'university'}
    +        res = helpers.node_colours(fnora)
    +
    +        self.assertEqual(res, "lightgrey")
    +
    + +
    +
    + + +
    +

    Ancestors (in MRO)

    +
      +
    • TestNetAttr
    • +
    • unittest.case.TestCase
    • +
    • builtins.object
    • +
    +

    Class variables

    +
    +

    var failureException

    + + + + +
    +
    + +
    +
    +

    var longMessage

    + + + + +
    +
    + +
    +
    +

    var maxDiff

    + + + + +
    +
    + +
    +

    Static methods

    + +
    +
    +

    def __init__(

    self, methodName='runTest')

    +
    + + + + +

    Create an instance of the class that will use the named test +method when executed. Raises a ValueError if the instance does +not have a method with the specified name.

    +
    + +
    +
    def __init__(self, methodName='runTest'):
    +    """Create an instance of the class that will use the named test
    +       method when executed. Raises a ValueError if the instance does
    +       not have a method with the specified name.
    +    """
    +    self._testMethodName = methodName
    +    self._outcome = None
    +    self._testMethodDoc = 'No test'
    +    try:
    +        testMethod = getattr(self, methodName)
    +    except AttributeError:
    +        if methodName != 'runTest':
    +            # we allow instantiation with no explicit method name
    +            # but not an *incorrect* or missing method name
    +            raise ValueError("no such test method in %s: %s" %
    +                  (self.__class__, methodName))
    +    else:
    +        self._testMethodDoc = testMethod.__doc__
    +    self._cleanups = []
    +    self._subtest = None
    +    # Map types to custom assertEqual functions that will compare
    +    # instances of said type in more detail to generate a more useful
    +    # error message.
    +    self._type_equality_funcs = {}
    +    self.addTypeEqualityFunc(dict, 'assertDictEqual')
    +    self.addTypeEqualityFunc(list, 'assertListEqual')
    +    self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
    +    self.addTypeEqualityFunc(set, 'assertSetEqual')
    +    self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
    +    self.addTypeEqualityFunc(str, 'assertMultiLineEqual')
    +
    + +
    +
    + +
    + + +
    +
    +

    def addCleanup(

    self, function, *args, **kwargs)

    +
    + + + + +

    Add a function, with arguments, to be called when the test is +completed. Functions added are called on a LIFO basis and are +called after tearDown on test failure or success.

    +

    Cleanup items are called even if setUp fails (unlike tearDown).

    +
    + +
    +
    def addCleanup(self, function, *args, **kwargs):
    +    """Add a function, with arguments, to be called when the test is
    +    completed. Functions added are called on a LIFO basis and are
    +    called after tearDown on test failure or success.
    +    Cleanup items are called even if setUp fails (unlike tearDown)."""
    +    self._cleanups.append((function, args, kwargs))
    +
    + +
    +
    + +
    + + +
    +
    +

    def addTypeEqualityFunc(

    self, typeobj, function)

    +
    + + + + +

    Add a type specific assertEqual style function to compare a type.

    +

    This method is for use by TestCase subclasses that need to register +their own type equality functions to provide nicer error messages.

    +

    Args: + typeobj: The data type to call this function on when both values + are of the same type in assertEqual(). + function: The callable taking two arguments and an optional + msg= argument that raises self.failureException with a + useful error message when the two arguments are not equal.

    +
    + +
    +
    def addTypeEqualityFunc(self, typeobj, function):
    +    """Add a type specific assertEqual style function to compare a type.
    +    This method is for use by TestCase subclasses that need to register
    +    their own type equality functions to provide nicer error messages.
    +    Args:
    +        typeobj: The data type to call this function on when both values
    +                are of the same type in assertEqual().
    +        function: The callable taking two arguments and an optional
    +                msg= argument that raises self.failureException with a
    +                useful error message when the two arguments are not equal.
    +    """
    +    self._type_equality_funcs[typeobj] = function
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertAlmostEqual(

    self, first, second, places=None, msg=None, delta=None)

    +
    + + + + +

    Fail if the two objects are unequal as determined by their +difference rounded to the given number of decimal places +(default 7) and comparing to zero, or by comparing that the +between the two objects is more than the given delta.

    +

    Note that decimal places (from zero) are usually not the same +as significant digits (measured from the most signficant digit).

    +

    If the two objects compare equal then they will automatically +compare almost equal.

    +
    + +
    +
    def assertAlmostEqual(self, first, second, places=None, msg=None,
    +                      delta=None):
    +    """Fail if the two objects are unequal as determined by their
    +       difference rounded to the given number of decimal places
    +       (default 7) and comparing to zero, or by comparing that the
    +       between the two objects is more than the given delta.
    +       Note that decimal places (from zero) are usually not the same
    +       as significant digits (measured from the most signficant digit).
    +       If the two objects compare equal then they will automatically
    +       compare almost equal.
    +    """
    +    if first == second:
    +        # shortcut
    +        return
    +    if delta is not None and places is not None:
    +        raise TypeError("specify delta or places not both")
    +    if delta is not None:
    +        if abs(first - second) <= delta:
    +            return
    +        standardMsg = '%s != %s within %s delta' % (safe_repr(first),
    +                                                    safe_repr(second),
    +                                                    safe_repr(delta))
    +    else:
    +        if places is None:
    +            places = 7
    +        if round(abs(second-first), places) == 0:
    +            return
    +        standardMsg = '%s != %s within %r places' % (safe_repr(first),
    +                                                      safe_repr(second),
    +                                                      places)
    +    msg = self._formatMessage(msg, standardMsg)
    +    raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertAlmostEquals(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertCountEqual(

    self, first, second, msg=None)

    +
    + + + + +

    An unordered sequence comparison asserting that the same elements, +regardless of order. If the same element occurs more than once, +it verifies that the elements occur the same number of times.

    +
    self.assertEqual(Counter(list(first)),
    +                 Counter(list(second)))
    +
    + + +

    Example: + - [0, 1, 1] and [1, 0, 1] compare equal. + - [0, 0, 1] and [0, 1] compare unequal.

    +
    + +
    +
    def assertCountEqual(self, first, second, msg=None):
    +    """An unordered sequence comparison asserting that the same elements,
    +    regardless of order.  If the same element occurs more than once,
    +    it verifies that the elements occur the same number of times.
    +        self.assertEqual(Counter(list(first)),
    +                         Counter(list(second)))
    +     Example:
    +        - [0, 1, 1] and [1, 0, 1] compare equal.
    +        - [0, 0, 1] and [0, 1] compare unequal.
    +    """
    +    first_seq, second_seq = list(first), list(second)
    +    try:
    +        first = collections.Counter(first_seq)
    +        second = collections.Counter(second_seq)
    +    except TypeError:
    +        # Handle case with unhashable elements
    +        differences = _count_diff_all_purpose(first_seq, second_seq)
    +    else:
    +        if first == second:
    +            return
    +        differences = _count_diff_hashable(first_seq, second_seq)
    +    if differences:
    +        standardMsg = 'Element counts were not equal:\n'
    +        lines = ['First has %d, Second has %d:  %r' % diff for diff in differences]
    +        diffMsg = '\n'.join(lines)
    +        standardMsg = self._truncateMessage(standardMsg, diffMsg)
    +        msg = self._formatMessage(msg, standardMsg)
    +        self.fail(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertDictContainsSubset(

    self, subset, dictionary, msg=None)

    +
    + + + + +

    Checks whether dictionary is a superset of subset.

    +
    + +
    +
    def assertDictContainsSubset(self, subset, dictionary, msg=None):
    +    """Checks whether dictionary is a superset of subset."""
    +    warnings.warn('assertDictContainsSubset is deprecated',
    +                  DeprecationWarning)
    +    missing = []
    +    mismatched = []
    +    for key, value in subset.items():
    +        if key not in dictionary:
    +            missing.append(key)
    +        elif value != dictionary[key]:
    +            mismatched.append('%s, expected: %s, actual: %s' %
    +                              (safe_repr(key), safe_repr(value),
    +                               safe_repr(dictionary[key])))
    +    if not (missing or mismatched):
    +        return
    +    standardMsg = ''
    +    if missing:
    +        standardMsg = 'Missing: %s' % ','.join(safe_repr(m) for m in
    +                                                missing)
    +    if mismatched:
    +        if standardMsg:
    +            standardMsg += '; '
    +        standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
    +    self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertDictEqual(

    self, d1, d2, msg=None)

    +
    + + + + +
    + +
    +
    def assertDictEqual(self, d1, d2, msg=None):
    +    self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
    +    self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
    +    if d1 != d2:
    +        standardMsg = '%s != %s' % _common_shorten_repr(d1, d2)
    +        diff = ('\n' + '\n'.join(difflib.ndiff(
    +                       pprint.pformat(d1).splitlines(),
    +                       pprint.pformat(d2).splitlines())))
    +        standardMsg = self._truncateMessage(standardMsg, diff)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertEqual(

    self, first, second, msg=None)

    +
    + + + + +

    Fail if the two objects are unequal as determined by the '==' +operator.

    +
    + +
    +
    def assertEqual(self, first, second, msg=None):
    +    """Fail if the two objects are unequal as determined by the '=='
    +       operator.
    +    """
    +    assertion_func = self._getAssertEqualityFunc(first, second)
    +    assertion_func(first, second, msg=msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertEquals(

    *args, **kwargs)

    +
    + + + + +
    + +
    +
    def deprecated_func(*args, **kwargs):
    +    warnings.warn(
    +        'Please use {0} instead.'.format(original_func.__name__),
    +        DeprecationWarning, 2)
    +    return original_func(*args, **kwargs)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertFalse(

    self, expr, msg=None)

    +
    + + + + +

    Check that the expression is false.

    +
    + +
    +
    def assertFalse(self, expr, msg=None):
    +    """Check that the expression is false."""
    +    if expr:
    +        msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
    +        raise self.failureException(msg)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertGreater(

    self, a, b, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a > b), but with a nicer default message.

    +
    + +
    +
    def assertGreater(self, a, b, msg=None):
    +    """Just like self.assertTrue(a > b), but with a nicer default message."""
    +    if not a > b:
    +        standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertGreaterEqual(

    self, a, b, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a >= b), but with a nicer default message.

    +
    + +
    +
    def assertGreaterEqual(self, a, b, msg=None):
    +    """Just like self.assertTrue(a >= b), but with a nicer default message."""
    +    if not a >= b:
    +        standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIn(

    self, member, container, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a in b), but with a nicer default message.

    +
    + +
    +
    def assertIn(self, member, container, msg=None):
    +    """Just like self.assertTrue(a in b), but with a nicer default message."""
    +    if member not in container:
    +        standardMsg = '%s not found in %s' % (safe_repr(member),
    +                                              safe_repr(container))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIs(

    self, expr1, expr2, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a is b), but with a nicer default message.

    +
    + +
    +
    def assertIs(self, expr1, expr2, msg=None):
    +    """Just like self.assertTrue(a is b), but with a nicer default message."""
    +    if expr1 is not expr2:
    +        standardMsg = '%s is not %s' % (safe_repr(expr1),
    +                                         safe_repr(expr2))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIsInstance(

    self, obj, cls, msg=None)

    +
    + + + + +

    Same as self.assertTrue(isinstance(obj, cls)), with a nicer +default message.

    +
    + +
    +
    def assertIsInstance(self, obj, cls, msg=None):
    +    """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
    +    default message."""
    +    if not isinstance(obj, cls):
    +        standardMsg = '%s is not an instance of %r' % (safe_repr(obj), cls)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIsNone(

    self, obj, msg=None)

    +
    + + + + +

    Same as self.assertTrue(obj is None), with a nicer default message.

    +
    + +
    +
    def assertIsNone(self, obj, msg=None):
    +    """Same as self.assertTrue(obj is None), with a nicer default message."""
    +    if obj is not None:
    +        standardMsg = '%s is not None' % (safe_repr(obj),)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIsNot(

    self, expr1, expr2, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a is not b), but with a nicer default message.

    +
    + +
    +
    def assertIsNot(self, expr1, expr2, msg=None):
    +    """Just like self.assertTrue(a is not b), but with a nicer default message."""
    +    if expr1 is expr2:
    +        standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),)
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertIsNotNone(

    self, obj, msg=None)

    +
    + + + + +

    Included for symmetry with assertIsNone.

    +
    + +
    +
    def assertIsNotNone(self, obj, msg=None):
    +    """Included for symmetry with assertIsNone."""
    +    if obj is None:
    +        standardMsg = 'unexpectedly None'
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertLess(

    self, a, b, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a < b), but with a nicer default message.

    +
    + +
    +
    def assertLess(self, a, b, msg=None):
    +    """Just like self.assertTrue(a < b), but with a nicer default message."""
    +    if not a < b:
    +        standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertLessEqual(

    self, a, b, msg=None)

    +
    + + + + +

    Just like self.assertTrue(a <= b), but with a nicer default message.

    +
    + +
    +
    def assertLessEqual(self, a, b, msg=None):
    +    """Just like self.assertTrue(a <= b), but with a nicer default message."""
    +    if not a <= b:
    +        standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b))
    +        self.fail(self._formatMessage(msg, standardMsg))
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertListEqual(

    self, list1, list2, msg=None)

    +
    + + + + +

    A list-specific equality assertion.

    +

    Args: + list1: The first list to compare. + list2: The second list to compare. + msg: Optional message to use on failure instead of a list of + differences.

    +
    + +
    +
    def assertListEqual(self, list1, list2, msg=None):
    +    """A list-specific equality assertion.
    +    Args:
    +        list1: The first list to compare.
    +        list2: The second list to compare.
    +        msg: Optional message to use on failure instead of a list of
    +                differences.
    +    """
    +    self.assertSequenceEqual(list1, list2, msg, seq_type=list)
    +
    + +
    +
    + +
    + + +
    +
    +

    def assertLogs(

    self, logger=None, level=None)

    +
    + + + + +

    Fail unless a log message of level level or higher is emitted +on logger_name or its children. If omitted, level defaults to +INFO and logger defaults to the root logger.

    +

    This method must be used as a context manager, and will yield +a recording object with two attributes: output and records. +At the end of the context manager, the output attribute will +be a list of the matching formatted log messages and the +records attribute will be a list of the corresponding LogRecord +objects.

    +

    Example::

    +
    with self.assertLogs('foo', level='INFO') as cm:
    +    logging.getLogger('foo').info('first message')
    +    logging.getLogger('foo.bar').error('second message')
    +self.assertEqual(cm.output, ['INFO:foo:first message',
    +                             'ERROR:foo.bar:second message'])
    +
    +
    + +
    +
    def assertLogs(self, logger=None, level=None):
    +    """Fail unless a log message of level *level* or higher is emitted
    +    on *logger_name* or its children.  If omitted, *level* defaults to
    +    INFO and *logger* defaults to the root logger.
    +    This method must be used as a context manager, and will yield
    +    a recording object with two attributes: `output` and `records`.
    +    At the end of the context manager, the `output` attribute will
    +    be a list of the matching formatted log messages and the
    +    `records` attribute will be a list of the corresponding LogRecord
    +    objects.
    +    Example::
    +        with self.assertLogs('foo', level='INFO') as cm:
    +            logging.getLogger('foo').info('first message')
    +            logging.getLogger('foo.bar').error('second message')
    +        self.assertEqual(cm.output, ['INFO:foo:first message',
    +                                     'ERROR:foo.bar:second message'])
    +    """
    +    return _AssertLogsContext(self, logger, level)
    +
    + +
    +
    + +
    + + +
    +

    def assertMultiLineEqual(

    self, first, second, msg=None)

    @@ -12693,12 +14934,11 @@

    Static methods

    unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
    @@ -12708,45 +14948,21 @@

    Static methods

    -
    -
    -

    def assertNotRegexpMatches(

    *args, **kwargs)

    -
    - - - - -
    - -
    -
    def deprecated_func(*args, **kwargs):
    -    warnings.warn(
    -        'Please use {0} instead.'.format(original_func.__name__),
    -        DeprecationWarning, 2)
    -    return original_func(*args, **kwargs)
    -
    - -
    -
    - -
    - -
    -

    def assertRaises(

    self, expected_exception, *args, **kwargs)

    +

    def assertRaises(

    self, excClass, callableObj=None, *args, **kwargs)

    -

    Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

    Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callableObj omitted or None, will return a context object used like this::

     with self.assertRaises(SomeException):
          do_something()
    @@ -12766,14 +14982,14 @@ 

    Static methods

    -
    def assertRaises(self, expected_exception, *args, **kwargs):
    -    """Fail unless an exception of class expected_exception is raised
    -       by the callable when invoked with specified positional and
    -       keyword arguments. If a different type of exception is
    +    
    def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
    +    """Fail unless an exception of class excClass is raised
    +       by callableObj when invoked with arguments args and keyword
    +       arguments kwargs. If a different type of exception is
            raised, it will not be caught, and the test case will be
            deemed to have suffered an error, exactly as for an
            unexpected exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callableObj omitted or None, will return a
            context object used like this::
                 with self.assertRaises(SomeException):
                     do_something()
    @@ -12787,8 +15003,8 @@ 

    Static methods

    the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
    @@ -12799,7 +15015,7 @@

    Static methods

    -

    def assertRaisesRegex(

    self, expected_exception, expected_regex, *args, **kwargs)

    +

    def assertRaisesRegex(

    self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -12810,27 +15026,30 @@

    Static methods

    expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

    + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertRaisesRegex(self, expected_exception, expected_regex,
    -                      *args, **kwargs):
    +                      callable_obj=None, *args, **kwargs):
         """Asserts that the message in a raised exception matches a regex.
         Args:
             expected_exception: Exception class expected to be raised.
             expected_regex: Regex (re pattern object or string) expected
                     to be found in error message.
    -        args: Function to be called and extra positional args.
    -        kwargs: Extra kwargs.
    +        callable_obj: Function to be called.
             msg: Optional message used in case of failure. Can only be used
                     when assertRaisesRegex is used as a context manager.
    +        args: Extra args.
    +        kwargs: Extra kwargs.
         """
    -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
    -    return context.handle('assertRaisesRegex', args, kwargs)
    +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
    +                                   expected_regex)
    +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
     
    @@ -12881,10 +15100,8 @@

    Static methods

    assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
    @@ -13159,19 +15376,19 @@

    Static methods

    -

    def assertWarns(

    self, expected_warning, *args, **kwargs)

    +

    def assertWarns(

    self, expected_warning, callable_obj=None, *args, **kwargs)

    Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

    -

    If called with the callable and arguments omitted, will return a +

    If called with callable_obj omitted or None, will return a context object used like this::

     with self.assertWarns(SomeWarning):
          do_something()
    @@ -13193,14 +15410,14 @@ 

    Static methods

    -
    def assertWarns(self, expected_warning, *args, **kwargs):
    +    
    def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
         """Fail unless a warning of class warnClass is triggered
    -       by the callable when invoked with specified positional and
    -       keyword arguments.  If a different type of warning is
    +       by callable_obj when invoked with arguments args and keyword
    +       arguments kwargs.  If a different type of warning is
            triggered, it will not be handled: depending on the other
            warning filtering rules in effect, it might be silenced, printed
            out, or raised as an exception.
    -       If called with the callable and arguments omitted, will return a
    +       If called with callable_obj omitted or None, will return a
            context object used like this::
                 with self.assertWarns(SomeWarning):
                     do_something()
    @@ -13216,8 +15433,8 @@ 

    Static methods

    the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
    @@ -13228,7 +15445,7 @@

    Static methods

    -

    def assertWarnsRegex(

    self, expected_warning, expected_regex, *args, **kwargs)

    +

    def assertWarnsRegex(

    self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

    @@ -13242,15 +15459,16 @@

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

    + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

    def assertWarnsRegex(self, expected_warning, expected_regex,
    -                     *args, **kwargs):
    +                     callable_obj=None, *args, **kwargs):
         """Asserts that the message in a triggered warning matches a regexp.
         Basic functioning is similar to assertWarns() with the addition
         that only warnings whose messages also match the regular expression
    @@ -13259,13 +15477,15 @@ 

    Static methods

    expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
    @@ -13701,7 +15921,6 @@

    Static methods

    -

    Hook method for setting up the test fixture before exercising it.

    diff --git a/docs/gitnet/gitnet_tests/test_log.m.html b/docs/gitnet/gitnet_tests/test_log.m.html index b01fe97..1d9ea21 100644 --- a/docs/gitnet/gitnet_tests/test_log.m.html +++ b/docs/gitnet/gitnet_tests/test_log.m.html @@ -1040,6 +1040,81 @@

    Index

  • Classes

      +
    • + AddAttributeTest + + + + +
    • AttributesTests @@ -1076,7 +1151,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1152,7 +1226,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1228,7 +1301,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1303,7 +1375,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1378,7 +1449,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1454,7 +1524,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1532,7 +1601,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1614,7 +1682,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1691,7 +1758,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1767,7 +1833,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1846,7 +1911,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1920,7 +1984,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1996,7 +2059,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -2074,7 +2136,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -2151,7 +2212,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -2227,7 +2287,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -2304,7 +2363,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -2459,13 +2517,58 @@

      gitnet.gitnet_tests.test_log module< cl = gitnet.get_log(path) attr_list = cl.attributes() - exp_attr_list = {"hash","author","email","date","mode","summary", + exp_attr_list = {"hash","author","email","domain","date","utc_date","utc_datetime","mode","summary", "fedits","inserts","message","files","changes"} self.assertSetEqual(set(attr_list), exp_attr_list) # Delete the temporary .git folder sub.call(["rm", "-rf", ".git"]) +class AddAttributeTest(unittest.TestCase): + """ + Tests for the add_attribute method. + """ + def setUp(self): + data = {"Bob": {"author": 'Bob', + "email": 'bob@gmail.com', + "type": 'author', + "loc": 'Waterloo', + "books": ['BookA', 'BookB']}, + "Bobby": {"author": 'Bobby', + "email": 'bobby@gmail.com', + "type": 'author', + "loc": 'Kitchener', + "books": ['BookC', 'BookD']}, + "Robert": {"author": 'Robert', + "email": 'robby@gmail.com', + "type": 'author', + "loc": 'Kitchener', + "books": ['BookC', 'BookD']}} + self.log = gitnet.Log(data) + + def test_new_attr_1(self): + new_log = self.log.add_attribute("letter", lambda d: d["author"][0]) + self.assertEqual(new_log["Bob"]["letter"], "B") + self.assertEqual(new_log["Bobby"]["letter"], "B") + self.assertEqual(new_log["Robert"]["letter"], "R") + + def test_new_attr_1(self): + new_log = self.log.add_attribute("edge",lambda d: gitnet.net_edges_simple("v1","v2",d,["loc"])) + self.assertEqual(new_log["Bob"]["edge"], ("v1","v2",{"loc":"Waterloo"})) + self.assertEqual(new_log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"})) + self.assertEqual(new_log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"})) + + def test_new_attr_mutate_1(self): + self.log.mutate_attribute("letter", lambda d: d["author"][0]) + self.assertEqual(self.log["Bob"]["letter"], "B") + self.assertEqual(self.log["Bobby"]["letter"], "B") + self.assertEqual(self.log["Robert"]["letter"], "R") + + def test_new_attr_mutate_2(self): + self.log.mutate_attribute("edge",lambda d: gitnet.net_edges_simple("v1","v2",d,["loc"])) + self.assertEqual(self.log["Bob"]["edge"], ("v1","v2",{"loc":"Waterloo"})) + self.assertEqual(self.log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"})) + self.assertEqual(self.log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"})) class DescribeTests(unittest.TestCase): def setUp(self): @@ -2839,7 +2942,7 @@

      gitnet.gitnet_tests.test_log module< # Setting up the directory for the tsv self.made_tsv = False try: - self.tsv_str = self.log.tsv(fname='temp.tsv') + self.tsv_str = self.log.tsv('temp.tsv') self.path = os.getcwd() + '/temp.tsv' finally: self.made_tsv = True @@ -2851,7 +2954,7 @@

      gitnet.gitnet_tests.test_log module< # Check that a file exists where expected self.assertTrue(os.path.exists(self.path)) # Check a summary string is produced - self.assertEqual("Data written to temp.tsv", self.tsv_str) + self.assertIn("Data written to temp.tsv", self.tsv_str) def test_basic_nofn(self): """Is no file produced but a string given? """ @@ -2861,16 +2964,16 @@

      gitnet.gitnet_tests.test_log module< # Checking no file is created self.assertFalse(os.path.exists(self.path)) # Checking a correct string is returned - tsv_str = self.log.tsv() + tsv_str = self.log.tsv('temp.tsv') self.assertIsInstance(tsv_str, str) - self.assertIn('\t', tsv_str) + self.assertIn('t', tsv_str) def test_empty_cols(self): - tsv_str = self.log.tsv(empty_cols=True, fname='temp.tsv') + tsv_str = self.log.tsv('temp.tsv', empty_cols=True) # Checking file is created self.assertTrue(os.path.exists(self.path)) # Check a summary string is produced - self.assertEqual("Data written to temp.tsv", tsv_str) + self.assertIn("Data written to temp.tsv", tsv_str) def test_warnings(self): # Warning occurs non string values are forced to strings @@ -2878,7 +2981,7 @@

      gitnet.gitnet_tests.test_log module< # Ensure warnings are being shown warnings.simplefilter("always") # Trigger Warning - self.log.tsv() + self.log.tsv('temp.tsv') # Check Warning occurred self.assertIn("Non-string input forced to string", str(w[-1].message)) @@ -3625,7 +3728,7 @@

      gitnet.gitnet_tests.test_log module< # Delete our temporary written edges file if self.made_edges: - sub.call(['rm', 'temp_edges.txt']) + sub.call(['rm', '-rf', 'temp_edges.txt']) class WriteNodesTests(unittest.TestCase): @@ -3700,73 +3803,58 @@

      gitnet.gitnet_tests.test_log module<

      Classes

      -

      class AttributesTests

      +

      class AddAttributeTest

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      +

      Tests for the add_attribute method.

      - -
      -
      class AttributesTests(unittest.TestCase):
      +  
      +  
      +
      class AddAttributeTest(unittest.TestCase):
      +    """
      +    Tests for the add_attribute method.
      +    """
           def setUp(self):
      -        data = {"Alice": {"email": 'alice@gmail.com',
      -                          "type": 'author',
      -                          "loc": 'Waterloo'},
      -                "Bobby": {"email": 'bobby@gmail.com',
      +        data = {"Bob": {"author": 'Bob',
      +                        "email": 'bob@gmail.com',
      +                        "type": 'author',
      +                        "loc": 'Waterloo',
      +                        "books": ['BookA', 'BookB']},
      +                "Bobby": {"author": 'Bobby',
      +                          "email": 'bobby@gmail.com',
                                 "type": 'author',
      -                          "loc": 'Kitchener'}}
      -
      +                          "loc": 'Kitchener',
      +                          "books": ['BookC', 'BookD']},
      +                "Robert": {"author": 'Robert',
      +                           "email": 'robby@gmail.com',
      +                           "type": 'author',
      +                           "loc": 'Kitchener',
      +                           "books": ['BookC', 'BookD']}}
               self.log = gitnet.Log(data)
      -        self.attr = self.log.attributes()
       
      -    def test_basic(self):
      -        """Is a list returned from the method?"""
      -        self.assertIsInstance(self.attr, list)
      +    def test_new_attr_1(self):
      +        new_log = self.log.add_attribute("letter", lambda d: d["author"][0])
      +        self.assertEqual(new_log["Bob"]["letter"], "B")
      +        self.assertEqual(new_log["Bobby"]["letter"], "B")
      +        self.assertEqual(new_log["Robert"]["letter"], "R")
       
      -    def test_values(self):
      -        """Are the correct values returned by the method"""
      -        attr_list = ['email', 'loc', 'type']  # Sorted list
      -        self.assertListEqual(self.attr, attr_list)
      -
      -    def test_commit_log_values(self):
      -        """The same method pertains to a CommitLog, but the result may be different"""
      -        # Set up small network
      -        sub.call(["cp", "-R", "small_network_repo.git", ".git"])
      -        path = os.getcwd()
      -
      -        cl = gitnet.get_log(path)
      -        attr_list = cl.attributes()
      +    def test_new_attr_1(self):
      +        new_log = self.log.add_attribute("edge",lambda d: gitnet.net_edges_simple("v1","v2",d,["loc"]))
      +        self.assertEqual(new_log["Bob"]["edge"], ("v1","v2",{"loc":"Waterloo"}))
      +        self.assertEqual(new_log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"}))
      +        self.assertEqual(new_log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"}))
       
      -        exp_attr_list = {"hash","author","email","date","mode","summary",
      -                         "fedits","inserts","message","files","changes"}
      +    def test_new_attr_mutate_1(self):
      +        self.log.mutate_attribute("letter", lambda d: d["author"][0])
      +        self.assertEqual(self.log["Bob"]["letter"], "B")
      +        self.assertEqual(self.log["Bobby"]["letter"], "B")
      +        self.assertEqual(self.log["Robert"]["letter"], "R")
       
      -        self.assertSetEqual(set(attr_list), exp_attr_list)
      -        # Delete the temporary .git folder
      -        sub.call(["rm", "-rf", ".git"])
      +    def test_new_attr_mutate_2(self):
      +        self.log.mutate_attribute("edge",lambda d: gitnet.net_edges_simple("v1","v2",d,["loc"]))
      +        self.assertEqual(self.log["Bob"]["edge"], ("v1","v2",{"loc":"Waterloo"}))
      +        self.assertEqual(self.log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"}))
      +        self.assertEqual(self.log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"}))
       
      @@ -3776,13 +3864,13 @@

      Classes

      Ancestors (in MRO)

      Class variables

      -

      var failureException

      +

      var failureException

      @@ -3792,7 +3880,7 @@

      Class variables

      -

      var longMessage

      +

      var longMessage

      @@ -3802,7 +3890,7 @@

      Class variables

      -

      var maxDiff

      +

      var maxDiff

      @@ -3814,7 +3902,7 @@

      Class variables

      Static methods

      -
      +

      def __init__(

      self, methodName='runTest')

      @@ -3825,8 +3913,8 @@

      Static methods

      method when executed. Raises a ValueError if the instance does not have a method with the specified name.

      - -
      + +
      def __init__(self, methodName='runTest'):
           """Create an instance of the class that will use the named test
              method when executed. Raises a ValueError if the instance does
      @@ -3866,7 +3954,7 @@ 

      Static methods

      -
      +

      def addCleanup(

      self, function, *args, **kwargs)

      @@ -3878,8 +3966,8 @@

      Static methods

      called after tearDown on test failure or success.

      Cleanup items are called even if setUp fails (unlike tearDown).

      - -
      + +
      def addCleanup(self, function, *args, **kwargs):
           """Add a function, with arguments, to be called when the test is
           completed. Functions added are called on a LIFO basis and are
      @@ -3895,7 +3983,7 @@ 

      Static methods

      -
      +

      def addTypeEqualityFunc(

      self, typeobj, function)

      @@ -3912,8 +4000,8 @@

      Static methods

      msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.

      - -
      + +
      def addTypeEqualityFunc(self, typeobj, function):
           """Add a type specific assertEqual style function to compare a type.
           This method is for use by TestCase subclasses that need to register
      @@ -3935,7 +4023,7 @@ 

      Static methods

      -
      +

      def assertAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -3951,8 +4039,8 @@

      Static methods

      If the two objects compare equal then they will automatically compare almost equal.

      - -
      + +
      def assertAlmostEqual(self, first, second, places=None, msg=None,
                             delta=None):
           """Fail if the two objects are unequal as determined by their
      @@ -3994,7 +4082,7 @@ 

      Static methods

      -
      +

      def assertAlmostEquals(

      *args, **kwargs)

      @@ -4002,8 +4090,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -4018,7 +4106,7 @@ 

      Static methods

      -
      +

      def assertCountEqual(

      self, first, second, msg=None)

      @@ -4037,8 +4125,8 @@

      Static methods

      - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

      - -
      + +
      def assertCountEqual(self, first, second, msg=None):
           """An unordered sequence comparison asserting that the same elements,
           regardless of order.  If the same element occurs more than once,
      @@ -4076,7 +4164,7 @@ 

      Static methods

      -
      +

      def assertDictContainsSubset(

      self, subset, dictionary, msg=None)

      @@ -4085,8 +4173,8 @@

      Static methods

      Checks whether dictionary is a superset of subset.

      - -
      + +
      def assertDictContainsSubset(self, subset, dictionary, msg=None):
           """Checks whether dictionary is a superset of subset."""
           warnings.warn('assertDictContainsSubset is deprecated',
      @@ -4120,7 +4208,7 @@ 

      Static methods

      -
      +

      def assertDictEqual(

      self, d1, d2, msg=None)

      @@ -4128,8 +4216,8 @@

      Static methods

      - -
      + +
      def assertDictEqual(self, d1, d2, msg=None):
           self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
           self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
      @@ -4149,7 +4237,7 @@ 

      Static methods

      -
      +

      def assertEqual(

      self, first, second, msg=None)

      @@ -4159,8 +4247,8 @@

      Static methods

      Fail if the two objects are unequal as determined by the '==' operator.

      - -
      + +
      def assertEqual(self, first, second, msg=None):
           """Fail if the two objects are unequal as determined by the '=='
              operator.
      @@ -4176,7 +4264,7 @@ 

      Static methods

      -
      +

      def assertEquals(

      *args, **kwargs)

      @@ -4184,8 +4272,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -4200,7 +4288,7 @@ 

      Static methods

      -
      +

      def assertFalse(

      self, expr, msg=None)

      @@ -4209,8 +4297,8 @@

      Static methods

      Check that the expression is false.

      - -
      + +
      def assertFalse(self, expr, msg=None):
           """Check that the expression is false."""
           if expr:
      @@ -4225,7 +4313,7 @@ 

      Static methods

      -
      +

      def assertGreater(

      self, a, b, msg=None)

      @@ -4234,8 +4322,8 @@

      Static methods

      Just like self.assertTrue(a > b), but with a nicer default message.

      - -
      + +
      def assertGreater(self, a, b, msg=None):
           """Just like self.assertTrue(a > b), but with a nicer default message."""
           if not a > b:
      @@ -4250,7 +4338,7 @@ 

      Static methods

      -
      +

      def assertGreaterEqual(

      self, a, b, msg=None)

      @@ -4259,8 +4347,8 @@

      Static methods

      Just like self.assertTrue(a >= b), but with a nicer default message.

      - -
      + +
      def assertGreaterEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a >= b), but with a nicer default message."""
           if not a >= b:
      @@ -4275,7 +4363,7 @@ 

      Static methods

      -
      +

      def assertIn(

      self, member, container, msg=None)

      @@ -4284,8 +4372,8 @@

      Static methods

      Just like self.assertTrue(a in b), but with a nicer default message.

      - -
      + +
      def assertIn(self, member, container, msg=None):
           """Just like self.assertTrue(a in b), but with a nicer default message."""
           if member not in container:
      @@ -4301,7 +4389,7 @@ 

      Static methods

      -
      +

      def assertIs(

      self, expr1, expr2, msg=None)

      @@ -4310,8 +4398,8 @@

      Static methods

      Just like self.assertTrue(a is b), but with a nicer default message.

      - -
      + +
      def assertIs(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is b), but with a nicer default message."""
           if expr1 is not expr2:
      @@ -4327,7 +4415,7 @@ 

      Static methods

      -
      +

      def assertIsInstance(

      self, obj, cls, msg=None)

      @@ -4337,8 +4425,8 @@

      Static methods

      Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

      - -
      + +
      def assertIsInstance(self, obj, cls, msg=None):
           """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
           default message."""
      @@ -4354,7 +4442,7 @@ 

      Static methods

      -
      +

      def assertIsNone(

      self, obj, msg=None)

      @@ -4363,8 +4451,8 @@

      Static methods

      Same as self.assertTrue(obj is None), with a nicer default message.

      - -
      + +
      def assertIsNone(self, obj, msg=None):
           """Same as self.assertTrue(obj is None), with a nicer default message."""
           if obj is not None:
      @@ -4379,7 +4467,7 @@ 

      Static methods

      -
      +

      def assertIsNot(

      self, expr1, expr2, msg=None)

      @@ -4388,8 +4476,8 @@

      Static methods

      Just like self.assertTrue(a is not b), but with a nicer default message.

      - -
      + +
      def assertIsNot(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is not b), but with a nicer default message."""
           if expr1 is expr2:
      @@ -4404,7 +4492,7 @@ 

      Static methods

      -
      +

      def assertIsNotNone(

      self, obj, msg=None)

      @@ -4413,8 +4501,8 @@

      Static methods

      Included for symmetry with assertIsNone.

      - -
      + +
      def assertIsNotNone(self, obj, msg=None):
           """Included for symmetry with assertIsNone."""
           if obj is None:
      @@ -4429,7 +4517,7 @@ 

      Static methods

      -
      +

      def assertLess(

      self, a, b, msg=None)

      @@ -4438,8 +4526,8 @@

      Static methods

      Just like self.assertTrue(a < b), but with a nicer default message.

      - -
      + +
      def assertLess(self, a, b, msg=None):
           """Just like self.assertTrue(a < b), but with a nicer default message."""
           if not a < b:
      @@ -4454,7 +4542,7 @@ 

      Static methods

      -
      +

      def assertLessEqual(

      self, a, b, msg=None)

      @@ -4463,8 +4551,8 @@

      Static methods

      Just like self.assertTrue(a <= b), but with a nicer default message.

      - -
      + +
      def assertLessEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a <= b), but with a nicer default message."""
           if not a <= b:
      @@ -4479,7 +4567,7 @@ 

      Static methods

      -
      +

      def assertListEqual(

      self, list1, list2, msg=None)

      @@ -4493,8 +4581,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertListEqual(self, list1, list2, msg=None):
           """A list-specific equality assertion.
           Args:
      @@ -4513,7 +4601,7 @@ 

      Static methods

      -
      +

      def assertLogs(

      self, logger=None, level=None)

      @@ -4537,8 +4625,8 @@

      Static methods

      'ERROR:foo.bar:second message'])
      - -
      + +
      def assertLogs(self, logger=None, level=None):
           """Fail unless a log message of level *level* or higher is emitted
           on *logger_name* or its children.  If omitted, *level* defaults to
      @@ -4566,7 +4654,7 @@ 

      Static methods

      -
      +

      def assertMultiLineEqual(

      self, first, second, msg=None)

      @@ -4575,8 +4663,8 @@

      Static methods

      Assert that two multi-line strings are equal.

      - -
      + +
      def assertMultiLineEqual(self, first, second, msg=None):
           """Assert that two multi-line strings are equal."""
           self.assertIsInstance(first, str, 'First argument is not a string')
      @@ -4604,7 +4692,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -4619,8 +4707,8 @@

      Static methods

      as significant digits (measured from the most signficant digit).

      Objects that are equal automatically fail.

      - -
      + +
      def assertNotAlmostEqual(self, first, second, places=None, msg=None,
                                delta=None):
           """Fail if the two objects are equal as determined by their
      @@ -4658,7 +4746,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEquals(

      *args, **kwargs)

      @@ -4666,8 +4754,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -4682,7 +4770,7 @@ 

      Static methods

      -
      +

      def assertNotEqual(

      self, first, second, msg=None)

      @@ -4692,8 +4780,8 @@

      Static methods

      Fail if the two objects are equal as determined by the '!=' operator.

      - -
      + +
      def assertNotEqual(self, first, second, msg=None):
           """Fail if the two objects are equal as determined by the '!='
              operator.
      @@ -4711,7 +4799,7 @@ 

      Static methods

      -
      +

      def assertNotEquals(

      *args, **kwargs)

      @@ -4719,8 +4807,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -4735,7 +4823,7 @@ 

      Static methods

      -
      +

      def assertNotIn(

      self, member, container, msg=None)

      @@ -4744,8 +4832,8 @@

      Static methods

      Just like self.assertTrue(a not in b), but with a nicer default message.

      - -
      + +
      def assertNotIn(self, member, container, msg=None):
           """Just like self.assertTrue(a not in b), but with a nicer default message."""
           if member in container:
      @@ -4761,7 +4849,7 @@ 

      Static methods

      -
      +

      def assertNotIsInstance(

      self, obj, cls, msg=None)

      @@ -4770,8 +4858,8 @@

      Static methods

      Included for symmetry with assertIsInstance.

      - -
      + +
      def assertNotIsInstance(self, obj, cls, msg=None):
           """Included for symmetry with assertIsInstance."""
           if isinstance(obj, cls):
      @@ -4786,7 +4874,7 @@ 

      Static methods

      -
      +

      def assertNotRegex(

      self, text, unexpected_regex, msg=None)

      @@ -4795,20 +4883,19 @@

      Static methods

      Fail the test if the text matches the regular expression.

      - -
      + +
      def assertNotRegex(self, text, unexpected_regex, msg=None):
           """Fail the test if the text matches the regular expression."""
           if isinstance(unexpected_regex, (str, bytes)):
               unexpected_regex = re.compile(unexpected_regex)
           match = unexpected_regex.search(text)
           if match:
      -        standardMsg = 'Regex matched: %r matches %r in %r' % (
      -            text[match.start() : match.end()],
      -            unexpected_regex.pattern,
      -            text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex matched"
      +        msg = '%s: %r matches %r in %r' % (msg,
      +                                           text[match.start():match.end()],
      +                                           unexpected_regex.pattern,
      +                                           text)
               raise self.failureException(msg)
       
      @@ -4819,44 +4906,20 @@

      Static methods

      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      +
      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - - -
      -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      -
      - - - - -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -4874,16 +4937,16 @@ 

      Static methods

      self.assertEqual(the_exception.error_code, 3)
      - -
      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +  
      +  
      +
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -4897,8 +4960,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -4908,8 +4971,8 @@

      Static methods

      -
      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +
      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -4920,27 +4983,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -4950,7 +5016,7 @@

      Static methods

      -
      +

      def assertRaisesRegexp(

      *args, **kwargs)

      @@ -4958,8 +5024,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -4974,7 +5040,7 @@ 

      Static methods

      -
      +

      def assertRegex(

      self, text, expected_regex, msg=None)

      @@ -4983,18 +5049,16 @@

      Static methods

      Fail the test unless the text matches the regular expression.

      - -
      + +
      def assertRegex(self, text, expected_regex, msg=None):
           """Fail the test unless the text matches the regular expression."""
           if isinstance(expected_regex, (str, bytes)):
               assert expected_regex, "expected_regex must not be empty."
               expected_regex = re.compile(expected_regex)
           if not expected_regex.search(text):
      -        standardMsg = "Regex didn't match: %r not found in %r" % (
      -            expected_regex.pattern, text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex didn't match"
      +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
               raise self.failureException(msg)
       
      @@ -5005,7 +5069,7 @@

      Static methods

      -
      +

      def assertRegexpMatches(

      *args, **kwargs)

      @@ -5013,8 +5077,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5029,7 +5093,7 @@ 

      Static methods

      -
      +

      def assertSequenceEqual(

      self, seq1, seq2, msg=None, seq_type=None)

      @@ -5047,8 +5111,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
           """An equality assertion for ordered sequences (like lists and tuples).
           For the purposes of this function, a valid ordered sequence type is one
      @@ -5145,7 +5209,7 @@ 

      Static methods

      -
      +

      def assertSetEqual(

      self, set1, set2, msg=None)

      @@ -5162,8 +5226,8 @@

      Static methods

      is optimized for sets specifically (parameters must support a difference method).

      - -
      + +
      def assertSetEqual(self, set1, set2, msg=None):
           """A set-specific equality assertion.
           Args:
      @@ -5209,7 +5273,7 @@ 

      Static methods

      -
      +

      def assertTrue(

      self, expr, msg=None)

      @@ -5218,8 +5282,8 @@

      Static methods

      Check that the expression is true.

      - -
      + +
      def assertTrue(self, expr, msg=None):
           """Check that the expression is true."""
           if not expr:
      @@ -5234,7 +5298,7 @@ 

      Static methods

      -
      +

      def assertTupleEqual(

      self, tuple1, tuple2, msg=None)

      @@ -5248,8 +5312,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertTupleEqual(self, tuple1, tuple2, msg=None):
           """A tuple-specific equality assertion.
           Args:
      @@ -5268,20 +5332,20 @@ 

      Static methods

      -
      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +
      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -5301,16 +5365,16 @@ 

      Static methods

      self.assertEqual(the_warning.some_attribute, 147)
      - -
      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +  
      +  
      +
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -5326,8 +5390,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -5337,8 +5401,8 @@

      Static methods

      -
      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +
      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -5352,15 +5416,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -5369,13 +5434,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -5385,7 +5452,7 @@

      Static methods

      -
      +

      def assert_(

      *args, **kwargs)

      @@ -5393,8 +5460,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5409,7 +5476,7 @@ 

      Static methods

      -
      +

      def countTestCases(

      self)

      @@ -5417,8 +5484,8 @@

      Static methods

      - -
      + +
      def countTestCases(self):
           return 1
       
      @@ -5430,7 +5497,7 @@

      Static methods

      -
      +

      def debug(

      self)

      @@ -5439,8 +5506,8 @@

      Static methods

      Run the test without collecting errors in a TestResult

      - -
      + +
      def debug(self):
           """Run the test without collecting errors in a TestResult"""
           self.setUp()
      @@ -5458,7 +5525,7 @@ 

      Static methods

      -
      +

      def defaultTestResult(

      self)

      @@ -5466,8 +5533,8 @@

      Static methods

      - -
      + +
      def defaultTestResult(self):
           return result.TestResult()
       
      @@ -5479,7 +5546,7 @@

      Static methods

      -
      +

      def doCleanups(

      self)

      @@ -5489,8 +5556,8 @@

      Static methods

      Execute all cleanup functions. Normally called for you after tearDown.

      - -
      + +
      def doCleanups(self):
           """Execute all cleanup functions. Normally called for you after
           tearDown."""
      @@ -5511,7 +5578,7 @@ 

      Static methods

      -
      +

      def fail(

      self, msg=None)

      @@ -5520,8 +5587,8 @@

      Static methods

      Fail immediately, with the given message.

      - -
      + +
      def fail(self, msg=None):
           """Fail immediately, with the given message."""
           raise self.failureException(msg)
      @@ -5534,7 +5601,7 @@ 

      Static methods

      -
      +

      def failIf(

      *args, **kwargs)

      @@ -5542,8 +5609,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5558,7 +5625,7 @@ 

      Static methods

      -
      +

      def failIfAlmostEqual(

      *args, **kwargs)

      @@ -5566,8 +5633,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5582,7 +5649,7 @@ 

      Static methods

      -
      +

      def failIfEqual(

      *args, **kwargs)

      @@ -5590,8 +5657,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5606,7 +5673,7 @@ 

      Static methods

      -
      +

      def failUnless(

      *args, **kwargs)

      @@ -5614,8 +5681,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5630,7 +5697,7 @@ 

      Static methods

      -
      +

      def failUnlessAlmostEqual(

      *args, **kwargs)

      @@ -5638,8 +5705,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5654,7 +5721,7 @@ 

      Static methods

      -
      +

      def failUnlessEqual(

      *args, **kwargs)

      @@ -5662,8 +5729,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5678,7 +5745,7 @@ 

      Static methods

      -
      +

      def failUnlessRaises(

      *args, **kwargs)

      @@ -5686,8 +5753,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -5702,7 +5769,7 @@ 

      Static methods

      -
      +

      def id(

      self)

      @@ -5710,8 +5777,8 @@

      Static methods

      - -
      + +
      def id(self):
           return "%s.%s" % (strclass(self.__class__), self._testMethodName)
       
      @@ -5723,7 +5790,7 @@

      Static methods

      -
      +

      def run(

      self, result=None)

      @@ -5731,8 +5798,8 @@

      Static methods

      - -
      + +
      def run(self, result=None):
           orig_result = result
           if result is None:
      @@ -5804,26 +5871,33 @@ 

      Static methods

      -
      +

      def setUp(

      self)

      -

      Hook method for setting up the test fixture before exercising it.

      - -
      + +
      def setUp(self):
      -    data = {"Alice": {"email": 'alice@gmail.com',
      -                      "type": 'author',
      -                      "loc": 'Waterloo'},
      -            "Bobby": {"email": 'bobby@gmail.com',
      +    data = {"Bob": {"author": 'Bob',
      +                    "email": 'bob@gmail.com',
      +                    "type": 'author',
      +                    "loc": 'Waterloo',
      +                    "books": ['BookA', 'BookB']},
      +            "Bobby": {"author": 'Bobby',
      +                      "email": 'bobby@gmail.com',
                             "type": 'author',
      -                      "loc": 'Kitchener'}}
      +                      "loc": 'Kitchener',
      +                      "books": ['BookC', 'BookD']},
      +            "Robert": {"author": 'Robert',
      +                       "email": 'robby@gmail.com',
      +                       "type": 'author',
      +                       "loc": 'Kitchener',
      +                       "books": ['BookC', 'BookD']}}
           self.log = gitnet.Log(data)
      -    self.attr = self.log.attributes()
       
      @@ -5833,7 +5907,7 @@

      Static methods

      -
      +

      def shortDescription(

      self)

      @@ -5845,8 +5919,8 @@

      Static methods

      The default implementation of this method returns the first line of the specified test method's docstring.

      - -
      + +
      def shortDescription(self):
           """Returns a one-line description of the test, or None if no
           description has been provided.
      @@ -5864,7 +5938,7 @@ 

      Static methods

      -
      +

      def skipTest(

      self, reason)

      @@ -5873,8 +5947,8 @@

      Static methods

      Skip this test.

      - -
      + +
      def skipTest(self, reason):
           """Skip this test."""
           raise SkipTest(reason)
      @@ -5887,7 +5961,7 @@ 

      Static methods

      -
      +

      def subTest(

      *args, **kwds)

      @@ -5900,8 +5974,8 @@

      Static methods

      case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed.

      - -
      + +
      @contextlib.contextmanager
       def subTest(self, msg=None, **params):
           """Return a context manager that will return the enclosed block
      @@ -5941,7 +6015,7 @@ 

      Static methods

      -
      +

      def tearDown(

      self)

      @@ -5950,8 +6024,8 @@

      Static methods

      Hook method for deconstructing the test fixture after testing it.

      - -
      + +
      def tearDown(self):
           "Hook method for deconstructing the test fixture after testing it."
           pass
      @@ -5964,20 +6038,21 @@ 

      Static methods

      -
      -

      def test_basic(

      self)

      +
      +

      def test_new_attr_1(

      self)

      -

      Is a list returned from the method?

      - -
      -
      def test_basic(self):
      -    """Is a list returned from the method?"""
      -    self.assertIsInstance(self.attr, list)
      +  
      +  
      +
      def test_new_attr_1(self):
      +    new_log = self.log.add_attribute("edge",lambda d: gitnet.net_edges_simple("v1","v2",d,["loc"]))
      +    self.assertEqual(new_log["Bob"]["edge"], ("v1","v2",{"loc":"Waterloo"}))
      +    self.assertEqual(new_log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"}))
      +    self.assertEqual(new_log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"}))
       
      @@ -5987,29 +6062,21 @@

      Static methods

      -
      -

      def test_commit_log_values(

      self)

      +
      +

      def test_new_attr_mutate_1(

      self)

      -

      The same method pertains to a CommitLog, but the result may be different

      - -
      -
      def test_commit_log_values(self):
      -    """The same method pertains to a CommitLog, but the result may be different"""
      -    # Set up small network
      -    sub.call(["cp", "-R", "small_network_repo.git", ".git"])
      -    path = os.getcwd()
      -    cl = gitnet.get_log(path)
      -    attr_list = cl.attributes()
      -    exp_attr_list = {"hash","author","email","date","mode","summary",
      -                     "fedits","inserts","message","files","changes"}
      -    self.assertSetEqual(set(attr_list), exp_attr_list)
      -    # Delete the temporary .git folder
      -    sub.call(["rm", "-rf", ".git"])
      +  
      +  
      +
      def test_new_attr_mutate_1(self):
      +    self.log.mutate_attribute("letter", lambda d: d["author"][0])
      +    self.assertEqual(self.log["Bob"]["letter"], "B")
      +    self.assertEqual(self.log["Bobby"]["letter"], "B")
      +    self.assertEqual(self.log["Robert"]["letter"], "R")
       
      @@ -6019,21 +6086,21 @@

      Static methods

      -
      -

      def test_values(

      self)

      +
      +

      def test_new_attr_mutate_2(

      self)

      -

      Are the correct values returned by the method

      - -
      -
      def test_values(self):
      -    """Are the correct values returned by the method"""
      -    attr_list = ['email', 'loc', 'type']  # Sorted list
      -    self.assertListEqual(self.attr, attr_list)
      +  
      +  
      +
      def test_new_attr_mutate_2(self):
      +    self.log.mutate_attribute("edge",lambda d: gitnet.net_edges_simple("v1","v2",d,["loc"]))
      +    self.assertEqual(self.log["Bob"]["edge"], ("v1","v2",{"loc":"Waterloo"}))
      +    self.assertEqual(self.log["Bobby"]["edge"], ("v1","v2",{"loc":"Kitchener"}))
      +    self.assertEqual(self.log["Robert"]["edge"], ("v1","v2",{"loc":"Kitchener"}))
       
      @@ -6044,7 +6111,7 @@

      Static methods

      Methods

      -
      +

      def setUpClass(

      cls)

      @@ -6053,8 +6120,8 @@

      Methods

      Hook method for setting up class fixture before running tests in the class.

      - -
      + +
      @classmethod
       def setUpClass(cls):
           "Hook method for setting up class fixture before running tests in the class."
      @@ -6067,7 +6134,7 @@ 

      Methods

      -
      +

      def tearDownClass(

      cls)

      @@ -6076,8 +6143,8 @@

      Methods

      Hook method for deconstructing the class fixture after running all tests in the class.

      - -
      + +
      @classmethod
       def tearDownClass(cls):
           "Hook method for deconstructing the class fixture after running all tests in the class."
      @@ -6092,48 +6159,48 @@ 

      Methods

      -

      class AuthorEmailsTests

      +

      class AttributesTests

      -

      Tests for the author_email_list function.

      - -
      -
      class AuthorEmailsTests(unittest.TestCase):
      -    """
      -    Tests for the author_email_list function.
      -    """
      +  
      +  
      +
      class AttributesTests(unittest.TestCase):
           def setUp(self):
      -        data = {"Bob": {"author": 'Bob',
      -                        "email": 'bob@gmail.com',
      -                        "type": 'author',
      -                        "loc": 'Waterloo',
      -                        "books": ['BookA', 'BookB']},
      -                "Bobby": {"author": 'Bobby',
      -                          "email": 'bobby@gmail.com',
      +        data = {"Alice": {"email": 'alice@gmail.com',
                                 "type": 'author',
      -                          "loc": 'Kitchener',
      -                          "books": ['BookC', 'BookD']},
      -                "Robert": {"author": 'Robert',
      -                           "email": 'robby@gmail.com',
      -                           "type": 'author',
      -                           "loc": 'Kitchener',
      -                           "books": ['BookC', 'BookD']}}
      +                          "loc": 'Waterloo'},
      +                "Bobby": {"email": 'bobby@gmail.com',
      +                          "type": 'author',
      +                          "loc": 'Kitchener'}}
      +
               self.log = gitnet.Log(data)
      +        self.attr = self.log.attributes()
       
      -    def test_list_type(self):
      -        temp = self.log.author_email_list()
      -        self.assertIsInstance(temp, str)
      +    def test_basic(self):
      +        """Is a list returned from the method?"""
      +        self.assertIsInstance(self.attr, list)
       
      -    def test_output(self):
      -        temp = str(self.log.author_email_list())
      -        self.assertIn('robby@gmail.com   Robert', temp)
      -        self.assertIn('bob@gmail.com   Bob', temp)
      -        self.assertIn('bobby@gmail.com   Bobby', temp)
      +    def test_values(self):
      +        """Are the correct values returned by the method"""
      +        attr_list = ['email', 'loc', 'type']  # Sorted list
      +        self.assertListEqual(self.attr, attr_list)
       
      -    def test_list_length(self):
      -        temp = len(self.log.author_email_list())
      -        self.assertEqual(temp, 263)
      +    def test_commit_log_values(self):
      +        """The same method pertains to a CommitLog, but the result may be different"""
      +        # Set up small network
      +        sub.call(["cp", "-R", "small_network_repo.git", ".git"])
      +        path = os.getcwd()
      +
      +        cl = gitnet.get_log(path)
      +        attr_list = cl.attributes()
      +
      +        exp_attr_list = {"hash","author","email","domain","date","utc_date","utc_datetime","mode","summary",
      +                         "fedits","inserts","message","files","changes"}
      +
      +        self.assertSetEqual(set(attr_list), exp_attr_list)
      +        # Delete the temporary .git folder
      +        sub.call(["rm", "-rf", ".git"])
       
      @@ -6143,13 +6210,13 @@

      Methods

      Ancestors (in MRO)

      Class variables

      -

      var failureException

      +

      var failureException

      @@ -6159,7 +6226,7 @@

      Class variables

      -

      var longMessage

      +

      var longMessage

      @@ -6169,7 +6236,7 @@

      Class variables

      -

      var maxDiff

      +

      var maxDiff

      @@ -6181,7 +6248,7 @@

      Class variables

      Static methods

      -
      +

      def __init__(

      self, methodName='runTest')

      @@ -6192,8 +6259,8 @@

      Static methods

      method when executed. Raises a ValueError if the instance does not have a method with the specified name.

      - -
      + +
      def __init__(self, methodName='runTest'):
           """Create an instance of the class that will use the named test
              method when executed. Raises a ValueError if the instance does
      @@ -6233,7 +6300,7 @@ 

      Static methods

      -
      +

      def addCleanup(

      self, function, *args, **kwargs)

      @@ -6245,8 +6312,8 @@

      Static methods

      called after tearDown on test failure or success.

      Cleanup items are called even if setUp fails (unlike tearDown).

      - -
      + +
      def addCleanup(self, function, *args, **kwargs):
           """Add a function, with arguments, to be called when the test is
           completed. Functions added are called on a LIFO basis and are
      @@ -6262,7 +6329,7 @@ 

      Static methods

      -
      +

      def addTypeEqualityFunc(

      self, typeobj, function)

      @@ -6279,8 +6346,8 @@

      Static methods

      msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.

      - -
      + +
      def addTypeEqualityFunc(self, typeobj, function):
           """Add a type specific assertEqual style function to compare a type.
           This method is for use by TestCase subclasses that need to register
      @@ -6302,7 +6369,7 @@ 

      Static methods

      -
      +

      def assertAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -6318,8 +6385,8 @@

      Static methods

      If the two objects compare equal then they will automatically compare almost equal.

      - -
      + +
      def assertAlmostEqual(self, first, second, places=None, msg=None,
                             delta=None):
           """Fail if the two objects are unequal as determined by their
      @@ -6361,7 +6428,7 @@ 

      Static methods

      -
      +

      def assertAlmostEquals(

      *args, **kwargs)

      @@ -6369,8 +6436,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -6385,7 +6452,7 @@ 

      Static methods

      -
      +

      def assertCountEqual(

      self, first, second, msg=None)

      @@ -6404,8 +6471,8 @@

      Static methods

      - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

      - -
      + +
      def assertCountEqual(self, first, second, msg=None):
           """An unordered sequence comparison asserting that the same elements,
           regardless of order.  If the same element occurs more than once,
      @@ -6443,7 +6510,7 @@ 

      Static methods

      -
      +

      def assertDictContainsSubset(

      self, subset, dictionary, msg=None)

      @@ -6452,8 +6519,8 @@

      Static methods

      Checks whether dictionary is a superset of subset.

      - -
      + +
      def assertDictContainsSubset(self, subset, dictionary, msg=None):
           """Checks whether dictionary is a superset of subset."""
           warnings.warn('assertDictContainsSubset is deprecated',
      @@ -6487,7 +6554,7 @@ 

      Static methods

      -
      +

      def assertDictEqual(

      self, d1, d2, msg=None)

      @@ -6495,8 +6562,8 @@

      Static methods

      - -
      + +
      def assertDictEqual(self, d1, d2, msg=None):
           self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
           self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
      @@ -6516,7 +6583,7 @@ 

      Static methods

      -
      +

      def assertEqual(

      self, first, second, msg=None)

      @@ -6526,8 +6593,8 @@

      Static methods

      Fail if the two objects are unequal as determined by the '==' operator.

      - -
      + +
      def assertEqual(self, first, second, msg=None):
           """Fail if the two objects are unequal as determined by the '=='
              operator.
      @@ -6543,7 +6610,7 @@ 

      Static methods

      -
      +

      def assertEquals(

      *args, **kwargs)

      @@ -6551,8 +6618,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -6567,7 +6634,7 @@ 

      Static methods

      -
      +

      def assertFalse(

      self, expr, msg=None)

      @@ -6576,8 +6643,8 @@

      Static methods

      Check that the expression is false.

      - -
      + +
      def assertFalse(self, expr, msg=None):
           """Check that the expression is false."""
           if expr:
      @@ -6592,7 +6659,7 @@ 

      Static methods

      -
      +

      def assertGreater(

      self, a, b, msg=None)

      @@ -6601,8 +6668,8 @@

      Static methods

      Just like self.assertTrue(a > b), but with a nicer default message.

      - -
      + +
      def assertGreater(self, a, b, msg=None):
           """Just like self.assertTrue(a > b), but with a nicer default message."""
           if not a > b:
      @@ -6617,7 +6684,7 @@ 

      Static methods

      -
      +

      def assertGreaterEqual(

      self, a, b, msg=None)

      @@ -6626,8 +6693,8 @@

      Static methods

      Just like self.assertTrue(a >= b), but with a nicer default message.

      - -
      + +
      def assertGreaterEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a >= b), but with a nicer default message."""
           if not a >= b:
      @@ -6642,7 +6709,7 @@ 

      Static methods

      -
      +

      def assertIn(

      self, member, container, msg=None)

      @@ -6651,8 +6718,8 @@

      Static methods

      Just like self.assertTrue(a in b), but with a nicer default message.

      - -
      + +
      def assertIn(self, member, container, msg=None):
           """Just like self.assertTrue(a in b), but with a nicer default message."""
           if member not in container:
      @@ -6668,7 +6735,7 @@ 

      Static methods

      -
      +

      def assertIs(

      self, expr1, expr2, msg=None)

      @@ -6677,8 +6744,8 @@

      Static methods

      Just like self.assertTrue(a is b), but with a nicer default message.

      - -
      + +
      def assertIs(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is b), but with a nicer default message."""
           if expr1 is not expr2:
      @@ -6694,7 +6761,7 @@ 

      Static methods

      -
      +

      def assertIsInstance(

      self, obj, cls, msg=None)

      @@ -6704,8 +6771,8 @@

      Static methods

      Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

      - -
      + +
      def assertIsInstance(self, obj, cls, msg=None):
           """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
           default message."""
      @@ -6721,7 +6788,7 @@ 

      Static methods

      -
      +

      def assertIsNone(

      self, obj, msg=None)

      @@ -6730,8 +6797,8 @@

      Static methods

      Same as self.assertTrue(obj is None), with a nicer default message.

      - -
      + +
      def assertIsNone(self, obj, msg=None):
           """Same as self.assertTrue(obj is None), with a nicer default message."""
           if obj is not None:
      @@ -6746,7 +6813,7 @@ 

      Static methods

      -
      +

      def assertIsNot(

      self, expr1, expr2, msg=None)

      @@ -6755,8 +6822,8 @@

      Static methods

      Just like self.assertTrue(a is not b), but with a nicer default message.

      - -
      + +
      def assertIsNot(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is not b), but with a nicer default message."""
           if expr1 is expr2:
      @@ -6771,7 +6838,7 @@ 

      Static methods

      -
      +

      def assertIsNotNone(

      self, obj, msg=None)

      @@ -6780,8 +6847,8 @@

      Static methods

      Included for symmetry with assertIsNone.

      - -
      + +
      def assertIsNotNone(self, obj, msg=None):
           """Included for symmetry with assertIsNone."""
           if obj is None:
      @@ -6796,7 +6863,7 @@ 

      Static methods

      -
      +

      def assertLess(

      self, a, b, msg=None)

      @@ -6805,8 +6872,8 @@

      Static methods

      Just like self.assertTrue(a < b), but with a nicer default message.

      - -
      + +
      def assertLess(self, a, b, msg=None):
           """Just like self.assertTrue(a < b), but with a nicer default message."""
           if not a < b:
      @@ -6821,7 +6888,7 @@ 

      Static methods

      -
      +

      def assertLessEqual(

      self, a, b, msg=None)

      @@ -6830,8 +6897,8 @@

      Static methods

      Just like self.assertTrue(a <= b), but with a nicer default message.

      - -
      + +
      def assertLessEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a <= b), but with a nicer default message."""
           if not a <= b:
      @@ -6846,7 +6913,7 @@ 

      Static methods

      -
      +

      def assertListEqual(

      self, list1, list2, msg=None)

      @@ -6860,8 +6927,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertListEqual(self, list1, list2, msg=None):
           """A list-specific equality assertion.
           Args:
      @@ -6880,7 +6947,7 @@ 

      Static methods

      -
      +

      def assertLogs(

      self, logger=None, level=None)

      @@ -6904,8 +6971,8 @@

      Static methods

      'ERROR:foo.bar:second message'])
      - -
      + +
      def assertLogs(self, logger=None, level=None):
           """Fail unless a log message of level *level* or higher is emitted
           on *logger_name* or its children.  If omitted, *level* defaults to
      @@ -6933,7 +7000,7 @@ 

      Static methods

      -
      +

      def assertMultiLineEqual(

      self, first, second, msg=None)

      @@ -6942,8 +7009,8 @@

      Static methods

      Assert that two multi-line strings are equal.

      - -
      + +
      def assertMultiLineEqual(self, first, second, msg=None):
           """Assert that two multi-line strings are equal."""
           self.assertIsInstance(first, str, 'First argument is not a string')
      @@ -6971,7 +7038,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -6986,8 +7053,8 @@

      Static methods

      as significant digits (measured from the most signficant digit).

      Objects that are equal automatically fail.

      - -
      + +
      def assertNotAlmostEqual(self, first, second, places=None, msg=None,
                                delta=None):
           """Fail if the two objects are equal as determined by their
      @@ -7025,7 +7092,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEquals(

      *args, **kwargs)

      @@ -7033,8 +7100,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7049,7 +7116,7 @@ 

      Static methods

      -
      +

      def assertNotEqual(

      self, first, second, msg=None)

      @@ -7059,8 +7126,8 @@

      Static methods

      Fail if the two objects are equal as determined by the '!=' operator.

      - -
      + +
      def assertNotEqual(self, first, second, msg=None):
           """Fail if the two objects are equal as determined by the '!='
              operator.
      @@ -7078,7 +7145,7 @@ 

      Static methods

      -
      +

      def assertNotEquals(

      *args, **kwargs)

      @@ -7086,8 +7153,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7102,7 +7169,7 @@ 

      Static methods

      -
      +

      def assertNotIn(

      self, member, container, msg=None)

      @@ -7111,8 +7178,8 @@

      Static methods

      Just like self.assertTrue(a not in b), but with a nicer default message.

      - -
      + +
      def assertNotIn(self, member, container, msg=None):
           """Just like self.assertTrue(a not in b), but with a nicer default message."""
           if member in container:
      @@ -7128,7 +7195,7 @@ 

      Static methods

      -
      +

      def assertNotIsInstance(

      self, obj, cls, msg=None)

      @@ -7137,8 +7204,8 @@

      Static methods

      Included for symmetry with assertIsInstance.

      - -
      + +
      def assertNotIsInstance(self, obj, cls, msg=None):
           """Included for symmetry with assertIsInstance."""
           if isinstance(obj, cls):
      @@ -7153,7 +7220,7 @@ 

      Static methods

      -
      +

      def assertNotRegex(

      self, text, unexpected_regex, msg=None)

      @@ -7162,20 +7229,19 @@

      Static methods

      Fail the test if the text matches the regular expression.

      - -
      + +
      def assertNotRegex(self, text, unexpected_regex, msg=None):
           """Fail the test if the text matches the regular expression."""
           if isinstance(unexpected_regex, (str, bytes)):
               unexpected_regex = re.compile(unexpected_regex)
           match = unexpected_regex.search(text)
           if match:
      -        standardMsg = 'Regex matched: %r matches %r in %r' % (
      -            text[match.start() : match.end()],
      -            unexpected_regex.pattern,
      -            text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex matched"
      +        msg = '%s: %r matches %r in %r' % (msg,
      +                                           text[match.start():match.end()],
      +                                           unexpected_regex.pattern,
      +                                           text)
               raise self.failureException(msg)
       
      @@ -7186,44 +7252,20 @@

      Static methods

      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - - -
      -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +
      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -7241,16 +7283,16 @@ 

      Static methods

      self.assertEqual(the_exception.error_code, 3)
      - -
      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +  
      +  
      +
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -7264,8 +7306,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -7275,8 +7317,8 @@

      Static methods

      -
      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +
      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -7287,27 +7329,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -7317,7 +7362,7 @@

      Static methods

      -
      +

      def assertRaisesRegexp(

      *args, **kwargs)

      @@ -7325,8 +7370,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7341,7 +7386,7 @@ 

      Static methods

      -
      +

      def assertRegex(

      self, text, expected_regex, msg=None)

      @@ -7350,18 +7395,16 @@

      Static methods

      Fail the test unless the text matches the regular expression.

      - -
      + +
      def assertRegex(self, text, expected_regex, msg=None):
           """Fail the test unless the text matches the regular expression."""
           if isinstance(expected_regex, (str, bytes)):
               assert expected_regex, "expected_regex must not be empty."
               expected_regex = re.compile(expected_regex)
           if not expected_regex.search(text):
      -        standardMsg = "Regex didn't match: %r not found in %r" % (
      -            expected_regex.pattern, text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex didn't match"
      +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
               raise self.failureException(msg)
       
      @@ -7372,7 +7415,7 @@

      Static methods

      -
      +

      def assertRegexpMatches(

      *args, **kwargs)

      @@ -7380,8 +7423,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7396,7 +7439,7 @@ 

      Static methods

      -
      +

      def assertSequenceEqual(

      self, seq1, seq2, msg=None, seq_type=None)

      @@ -7414,8 +7457,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
           """An equality assertion for ordered sequences (like lists and tuples).
           For the purposes of this function, a valid ordered sequence type is one
      @@ -7512,7 +7555,7 @@ 

      Static methods

      -
      +

      def assertSetEqual(

      self, set1, set2, msg=None)

      @@ -7529,8 +7572,8 @@

      Static methods

      is optimized for sets specifically (parameters must support a difference method).

      - -
      + +
      def assertSetEqual(self, set1, set2, msg=None):
           """A set-specific equality assertion.
           Args:
      @@ -7576,7 +7619,7 @@ 

      Static methods

      -
      +

      def assertTrue(

      self, expr, msg=None)

      @@ -7585,8 +7628,8 @@

      Static methods

      Check that the expression is true.

      - -
      + +
      def assertTrue(self, expr, msg=None):
           """Check that the expression is true."""
           if not expr:
      @@ -7601,7 +7644,7 @@ 

      Static methods

      -
      +

      def assertTupleEqual(

      self, tuple1, tuple2, msg=None)

      @@ -7615,8 +7658,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertTupleEqual(self, tuple1, tuple2, msg=None):
           """A tuple-specific equality assertion.
           Args:
      @@ -7635,20 +7678,20 @@ 

      Static methods

      -
      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +
      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -7668,16 +7711,16 @@ 

      Static methods

      self.assertEqual(the_warning.some_attribute, 147)
      - -
      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +  
      +  
      +
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -7693,8 +7736,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -7704,8 +7747,8 @@

      Static methods

      -
      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +
      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -7719,15 +7762,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -7736,13 +7780,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -7752,7 +7798,7 @@

      Static methods

      -
      +

      def assert_(

      *args, **kwargs)

      @@ -7760,8 +7806,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7776,7 +7822,7 @@ 

      Static methods

      -
      +

      def countTestCases(

      self)

      @@ -7784,8 +7830,8 @@

      Static methods

      - -
      + +
      def countTestCases(self):
           return 1
       
      @@ -7797,7 +7843,7 @@

      Static methods

      -
      +

      def debug(

      self)

      @@ -7806,8 +7852,8 @@

      Static methods

      Run the test without collecting errors in a TestResult

      - -
      + +
      def debug(self):
           """Run the test without collecting errors in a TestResult"""
           self.setUp()
      @@ -7825,7 +7871,7 @@ 

      Static methods

      -
      +

      def defaultTestResult(

      self)

      @@ -7833,8 +7879,8 @@

      Static methods

      - -
      + +
      def defaultTestResult(self):
           return result.TestResult()
       
      @@ -7846,7 +7892,7 @@

      Static methods

      -
      +

      def doCleanups(

      self)

      @@ -7856,8 +7902,8 @@

      Static methods

      Execute all cleanup functions. Normally called for you after tearDown.

      - -
      + +
      def doCleanups(self):
           """Execute all cleanup functions. Normally called for you after
           tearDown."""
      @@ -7878,7 +7924,7 @@ 

      Static methods

      -
      +

      def fail(

      self, msg=None)

      @@ -7887,8 +7933,8 @@

      Static methods

      Fail immediately, with the given message.

      - -
      + +
      def fail(self, msg=None):
           """Fail immediately, with the given message."""
           raise self.failureException(msg)
      @@ -7901,7 +7947,7 @@ 

      Static methods

      -
      +

      def failIf(

      *args, **kwargs)

      @@ -7909,8 +7955,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7925,7 +7971,7 @@ 

      Static methods

      -
      +

      def failIfAlmostEqual(

      *args, **kwargs)

      @@ -7933,8 +7979,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7949,7 +7995,7 @@ 

      Static methods

      -
      +

      def failIfEqual(

      *args, **kwargs)

      @@ -7957,8 +8003,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7973,7 +8019,7 @@ 

      Static methods

      -
      +

      def failUnless(

      *args, **kwargs)

      @@ -7981,8 +8027,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -7997,7 +8043,7 @@ 

      Static methods

      -
      +

      def failUnlessAlmostEqual(

      *args, **kwargs)

      @@ -8005,8 +8051,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -8021,7 +8067,7 @@ 

      Static methods

      -
      +

      def failUnlessEqual(

      *args, **kwargs)

      @@ -8029,8 +8075,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -8045,7 +8091,7 @@ 

      Static methods

      -
      +

      def failUnlessRaises(

      *args, **kwargs)

      @@ -8053,8 +8099,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -8069,7 +8115,7 @@ 

      Static methods

      -
      +

      def id(

      self)

      @@ -8077,8 +8123,8 @@

      Static methods

      - -
      + +
      def id(self):
           return "%s.%s" % (strclass(self.__class__), self._testMethodName)
       
      @@ -8090,7 +8136,7 @@

      Static methods

      -
      +

      def run(

      self, result=None)

      @@ -8098,8 +8144,8 @@

      Static methods

      - -
      + +
      def run(self, result=None):
           orig_result = result
           if result is None:
      @@ -8171,34 +8217,25 @@ 

      Static methods

      -
      +

      def setUp(

      self)

      -

      Hook method for setting up the test fixture before exercising it.

      - -
      + +
      def setUp(self):
      -    data = {"Bob": {"author": 'Bob',
      -                    "email": 'bob@gmail.com',
      -                    "type": 'author',
      -                    "loc": 'Waterloo',
      -                    "books": ['BookA', 'BookB']},
      -            "Bobby": {"author": 'Bobby',
      -                      "email": 'bobby@gmail.com',
      +    data = {"Alice": {"email": 'alice@gmail.com',
                             "type": 'author',
      -                      "loc": 'Kitchener',
      -                      "books": ['BookC', 'BookD']},
      -            "Robert": {"author": 'Robert',
      -                       "email": 'robby@gmail.com',
      -                       "type": 'author',
      -                       "loc": 'Kitchener',
      -                       "books": ['BookC', 'BookD']}}
      +                      "loc": 'Waterloo'},
      +            "Bobby": {"email": 'bobby@gmail.com',
      +                      "type": 'author',
      +                      "loc": 'Kitchener'}}
           self.log = gitnet.Log(data)
      +    self.attr = self.log.attributes()
       
      @@ -8208,7 +8245,7 @@

      Static methods

      -
      +

      def shortDescription(

      self)

      @@ -8220,8 +8257,8 @@

      Static methods

      The default implementation of this method returns the first line of the specified test method's docstring.

      - -
      + +
      def shortDescription(self):
           """Returns a one-line description of the test, or None if no
           description has been provided.
      @@ -8239,7 +8276,7 @@ 

      Static methods

      -
      +

      def skipTest(

      self, reason)

      @@ -8248,8 +8285,8 @@

      Static methods

      Skip this test.

      - -
      + +
      def skipTest(self, reason):
           """Skip this test."""
           raise SkipTest(reason)
      @@ -8262,7 +8299,7 @@ 

      Static methods

      -
      +

      def subTest(

      *args, **kwds)

      @@ -8275,8 +8312,8 @@

      Static methods

      case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed.

      - -
      + +
      @contextlib.contextmanager
       def subTest(self, msg=None, **params):
           """Return a context manager that will return the enclosed block
      @@ -8316,7 +8353,7 @@ 

      Static methods

      -
      +

      def tearDown(

      self)

      @@ -8325,8 +8362,8 @@

      Static methods

      Hook method for deconstructing the test fixture after testing it.

      - -
      + +
      def tearDown(self):
           "Hook method for deconstructing the test fixture after testing it."
           pass
      @@ -8339,19 +8376,20 @@ 

      Static methods

      -
      -

      def test_list_length(

      self)

      +
      +

      def test_basic(

      self)

      +

      Is a list returned from the method?

      - -
      -
      def test_list_length(self):
      -    temp = len(self.log.author_email_list())
      -    self.assertEqual(temp, 263)
      +  
      +  
      +
      def test_basic(self):
      +    """Is a list returned from the method?"""
      +    self.assertIsInstance(self.attr, list)
       
      @@ -8361,19 +8399,29 @@

      Static methods

      -
      -

      def test_list_type(

      self)

      +
      +

      def test_commit_log_values(

      self)

      +

      The same method pertains to a CommitLog, but the result may be different

      - -
      -
      def test_list_type(self):
      -    temp = self.log.author_email_list()
      -    self.assertIsInstance(temp, str)
      +  
      +  
      +
      def test_commit_log_values(self):
      +    """The same method pertains to a CommitLog, but the result may be different"""
      +    # Set up small network
      +    sub.call(["cp", "-R", "small_network_repo.git", ".git"])
      +    path = os.getcwd()
      +    cl = gitnet.get_log(path)
      +    attr_list = cl.attributes()
      +    exp_attr_list = {"hash","author","email","domain","date","utc_date","utc_datetime","mode","summary",
      +                     "fedits","inserts","message","files","changes"}
      +    self.assertSetEqual(set(attr_list), exp_attr_list)
      +    # Delete the temporary .git folder
      +    sub.call(["rm", "-rf", ".git"])
       
      @@ -8383,21 +8431,21 @@

      Static methods

      -
      -

      def test_output(

      self)

      +
      +

      def test_values(

      self)

      +

      Are the correct values returned by the method

      - -
      -
      def test_output(self):
      -    temp = str(self.log.author_email_list())
      -    self.assertIn('robby@gmail.com   Robert', temp)
      -    self.assertIn('bob@gmail.com   Bob', temp)
      -    self.assertIn('bobby@gmail.com   Bobby', temp)
      +  
      +  
      +
      def test_values(self):
      +    """Are the correct values returned by the method"""
      +    attr_list = ['email', 'loc', 'type']  # Sorted list
      +    self.assertListEqual(self.attr, attr_list)
       
      @@ -8408,7 +8456,7 @@

      Static methods

      Methods

      -
      +

      def setUpClass(

      cls)

      @@ -8417,8 +8465,8 @@

      Methods

      Hook method for setting up class fixture before running tests in the class.

      - -
      + +
      @classmethod
       def setUpClass(cls):
           "Hook method for setting up class fixture before running tests in the class."
      @@ -8431,7 +8479,7 @@ 

      Methods

      -
      +

      def tearDownClass(

      cls)

      @@ -8440,8 +8488,8 @@

      Methods

      Hook method for deconstructing the class fixture after running all tests in the class.

      - -
      + +
      @classmethod
       def tearDownClass(cls):
           "Hook method for deconstructing the class fixture after running all tests in the class."
      @@ -8456,64 +8504,48 @@ 

      Methods

      -

      class BrowseTests

      +

      class AuthorEmailsTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      +

      Tests for the author_email_list function.

      - -
      -
      class BrowseTests(unittest.TestCase):
      +  
      +  
      +
      class AuthorEmailsTests(unittest.TestCase):
      +    """
      +    Tests for the author_email_list function.
      +    """
           def setUp(self):
      -        data = {"Alice": {"email": 'alice@gmail.com',
      -                          "type": 'author',
      -                          "loc": 'Waterloo',
      -                          "books": ['BookA', 'BookB']},
      -                "Bobby": {"email": 'bobby@gmail.com',
      +        data = {"Bob": {"author": 'Bob',
      +                        "email": 'bob@gmail.com',
      +                        "type": 'author',
      +                        "loc": 'Waterloo',
      +                        "books": ['BookA', 'BookB']},
      +                "Bobby": {"author": 'Bobby',
      +                          "email": 'bobby@gmail.com',
                                 "type": 'author',
                                 "loc": 'Kitchener',
      -                          "books": ['BookC', 'BookD']}}
      +                          "books": ['BookC', 'BookD']},
      +                "Robert": {"author": 'Robert',
      +                           "email": 'robby@gmail.com',
      +                           "type": 'author',
      +                           "loc": 'Kitchener',
      +                           "books": ['BookC', 'BookD']}}
               self.log = gitnet.Log(data)
       
      -    def test_quit(self):
      -        """Is the output as expected upon the input of q?"""
      -        with patch("sys.stdin", StringIO("q")), patch("sys.stdout", new_callable=StringIO) as fake_out:
      -            self.log.browse()
      -            self.assertTrue("-- Alice --" in fake_out.getvalue() and "-- Bobby --" not in fake_out.getvalue() or
      -                            "-- Bobby --" in fake_out.getvalue() and "-- Alice --" not in fake_out.getvalue())
      +    def test_list_type(self):
      +        temp = self.log.author_email_list()
      +        self.assertIsInstance(temp, str)
       
      -    def test_attr(self):
      -        with patch("sys.stdin", StringIO("q")), patch("sys.stdout", new_callable=StringIO) as fake_out:
      -            self.log.browse()
      -            self.assertTrue("Waterloo" in fake_out.getvalue() and "Kitchener" not in fake_out.getvalue() or
      -                            "Kitchener" in fake_out.getvalue() and "Waterloo" not in fake_out.getvalue())
      -            self.assertIn("author", fake_out.getvalue())
      -            self.assertTrue("BookA\nBookB" in fake_out.getvalue() and "BookC\nBookD" not in fake_out.getvalue() or
      -                            "BookC\nBookD" in fake_out.getvalue() and "BookA\nBookB" not in fake_out.getvalue())
      +    def test_output(self):
      +        temp = str(self.log.author_email_list())
      +        self.assertIn('robby@gmail.com   Robert', temp)
      +        self.assertIn('bob@gmail.com   Bob', temp)
      +        self.assertIn('bobby@gmail.com   Bobby', temp)
      +
      +    def test_list_length(self):
      +        temp = len(self.log.author_email_list())
      +        self.assertEqual(temp, 263)
       
      @@ -8523,13 +8555,13 @@

      Methods

      Ancestors (in MRO)

      Class variables

      -

      var failureException

      +

      var failureException

      @@ -8539,7 +8571,7 @@

      Class variables

      -

      var longMessage

      +

      var longMessage

      @@ -8549,7 +8581,7 @@

      Class variables

      -

      var maxDiff

      +

      var maxDiff

      @@ -8561,7 +8593,7 @@

      Class variables

      Static methods

      -
      +

      def __init__(

      self, methodName='runTest')

      @@ -8572,8 +8604,8 @@

      Static methods

      method when executed. Raises a ValueError if the instance does not have a method with the specified name.

      - -
      + +
      def __init__(self, methodName='runTest'):
           """Create an instance of the class that will use the named test
              method when executed. Raises a ValueError if the instance does
      @@ -8613,7 +8645,7 @@ 

      Static methods

      -
      +

      def addCleanup(

      self, function, *args, **kwargs)

      @@ -8625,8 +8657,8 @@

      Static methods

      called after tearDown on test failure or success.

      Cleanup items are called even if setUp fails (unlike tearDown).

      - -
      + +
      def addCleanup(self, function, *args, **kwargs):
           """Add a function, with arguments, to be called when the test is
           completed. Functions added are called on a LIFO basis and are
      @@ -8642,7 +8674,7 @@ 

      Static methods

      -
      +

      def addTypeEqualityFunc(

      self, typeobj, function)

      @@ -8659,8 +8691,8 @@

      Static methods

      msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.

      - -
      + +
      def addTypeEqualityFunc(self, typeobj, function):
           """Add a type specific assertEqual style function to compare a type.
           This method is for use by TestCase subclasses that need to register
      @@ -8682,7 +8714,7 @@ 

      Static methods

      -
      +

      def assertAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -8698,8 +8730,8 @@

      Static methods

      If the two objects compare equal then they will automatically compare almost equal.

      - -
      + +
      def assertAlmostEqual(self, first, second, places=None, msg=None,
                             delta=None):
           """Fail if the two objects are unequal as determined by their
      @@ -8741,7 +8773,7 @@ 

      Static methods

      -
      +

      def assertAlmostEquals(

      *args, **kwargs)

      @@ -8749,8 +8781,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -8765,7 +8797,7 @@ 

      Static methods

      -
      +

      def assertCountEqual(

      self, first, second, msg=None)

      @@ -8784,8 +8816,8 @@

      Static methods

      - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

      - -
      + +
      def assertCountEqual(self, first, second, msg=None):
           """An unordered sequence comparison asserting that the same elements,
           regardless of order.  If the same element occurs more than once,
      @@ -8823,7 +8855,7 @@ 

      Static methods

      -
      +

      def assertDictContainsSubset(

      self, subset, dictionary, msg=None)

      @@ -8832,8 +8864,8 @@

      Static methods

      Checks whether dictionary is a superset of subset.

      - -
      + +
      def assertDictContainsSubset(self, subset, dictionary, msg=None):
           """Checks whether dictionary is a superset of subset."""
           warnings.warn('assertDictContainsSubset is deprecated',
      @@ -8867,7 +8899,7 @@ 

      Static methods

      -
      +

      def assertDictEqual(

      self, d1, d2, msg=None)

      @@ -8875,8 +8907,8 @@

      Static methods

      - -
      + +
      def assertDictEqual(self, d1, d2, msg=None):
           self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
           self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
      @@ -8896,7 +8928,7 @@ 

      Static methods

      -
      +

      def assertEqual(

      self, first, second, msg=None)

      @@ -8906,8 +8938,8 @@

      Static methods

      Fail if the two objects are unequal as determined by the '==' operator.

      - -
      + +
      def assertEqual(self, first, second, msg=None):
           """Fail if the two objects are unequal as determined by the '=='
              operator.
      @@ -8923,7 +8955,7 @@ 

      Static methods

      -
      +

      def assertEquals(

      *args, **kwargs)

      @@ -8931,8 +8963,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -8947,7 +8979,7 @@ 

      Static methods

      -
      +

      def assertFalse(

      self, expr, msg=None)

      @@ -8956,8 +8988,8 @@

      Static methods

      Check that the expression is false.

      - -
      + +
      def assertFalse(self, expr, msg=None):
           """Check that the expression is false."""
           if expr:
      @@ -8972,7 +9004,7 @@ 

      Static methods

      -
      +

      def assertGreater(

      self, a, b, msg=None)

      @@ -8981,8 +9013,8 @@

      Static methods

      Just like self.assertTrue(a > b), but with a nicer default message.

      - -
      + +
      def assertGreater(self, a, b, msg=None):
           """Just like self.assertTrue(a > b), but with a nicer default message."""
           if not a > b:
      @@ -8997,7 +9029,7 @@ 

      Static methods

      -
      +

      def assertGreaterEqual(

      self, a, b, msg=None)

      @@ -9006,8 +9038,8 @@

      Static methods

      Just like self.assertTrue(a >= b), but with a nicer default message.

      - -
      + +
      def assertGreaterEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a >= b), but with a nicer default message."""
           if not a >= b:
      @@ -9022,7 +9054,7 @@ 

      Static methods

      -
      +

      def assertIn(

      self, member, container, msg=None)

      @@ -9031,8 +9063,8 @@

      Static methods

      Just like self.assertTrue(a in b), but with a nicer default message.

      - -
      + +
      def assertIn(self, member, container, msg=None):
           """Just like self.assertTrue(a in b), but with a nicer default message."""
           if member not in container:
      @@ -9048,7 +9080,7 @@ 

      Static methods

      -
      +

      def assertIs(

      self, expr1, expr2, msg=None)

      @@ -9057,8 +9089,8 @@

      Static methods

      Just like self.assertTrue(a is b), but with a nicer default message.

      - -
      + +
      def assertIs(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is b), but with a nicer default message."""
           if expr1 is not expr2:
      @@ -9074,7 +9106,7 @@ 

      Static methods

      -
      +

      def assertIsInstance(

      self, obj, cls, msg=None)

      @@ -9084,8 +9116,8 @@

      Static methods

      Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

      - -
      + +
      def assertIsInstance(self, obj, cls, msg=None):
           """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
           default message."""
      @@ -9101,7 +9133,7 @@ 

      Static methods

      -
      +

      def assertIsNone(

      self, obj, msg=None)

      @@ -9110,8 +9142,8 @@

      Static methods

      Same as self.assertTrue(obj is None), with a nicer default message.

      - -
      + +
      def assertIsNone(self, obj, msg=None):
           """Same as self.assertTrue(obj is None), with a nicer default message."""
           if obj is not None:
      @@ -9126,7 +9158,7 @@ 

      Static methods

      -
      +

      def assertIsNot(

      self, expr1, expr2, msg=None)

      @@ -9135,8 +9167,8 @@

      Static methods

      Just like self.assertTrue(a is not b), but with a nicer default message.

      - -
      + +
      def assertIsNot(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is not b), but with a nicer default message."""
           if expr1 is expr2:
      @@ -9151,7 +9183,7 @@ 

      Static methods

      -
      +

      def assertIsNotNone(

      self, obj, msg=None)

      @@ -9160,8 +9192,8 @@

      Static methods

      Included for symmetry with assertIsNone.

      - -
      + +
      def assertIsNotNone(self, obj, msg=None):
           """Included for symmetry with assertIsNone."""
           if obj is None:
      @@ -9176,7 +9208,7 @@ 

      Static methods

      -
      +

      def assertLess(

      self, a, b, msg=None)

      @@ -9185,8 +9217,8 @@

      Static methods

      Just like self.assertTrue(a < b), but with a nicer default message.

      - -
      + +
      def assertLess(self, a, b, msg=None):
           """Just like self.assertTrue(a < b), but with a nicer default message."""
           if not a < b:
      @@ -9201,7 +9233,7 @@ 

      Static methods

      -
      +

      def assertLessEqual(

      self, a, b, msg=None)

      @@ -9210,8 +9242,8 @@

      Static methods

      Just like self.assertTrue(a <= b), but with a nicer default message.

      - -
      + +
      def assertLessEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a <= b), but with a nicer default message."""
           if not a <= b:
      @@ -9226,7 +9258,7 @@ 

      Static methods

      -
      +

      def assertListEqual(

      self, list1, list2, msg=None)

      @@ -9240,8 +9272,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertListEqual(self, list1, list2, msg=None):
           """A list-specific equality assertion.
           Args:
      @@ -9260,7 +9292,7 @@ 

      Static methods

      -
      +

      def assertLogs(

      self, logger=None, level=None)

      @@ -9284,8 +9316,8 @@

      Static methods

      'ERROR:foo.bar:second message'])
      - -
      + +
      def assertLogs(self, logger=None, level=None):
           """Fail unless a log message of level *level* or higher is emitted
           on *logger_name* or its children.  If omitted, *level* defaults to
      @@ -9313,7 +9345,7 @@ 

      Static methods

      -
      +

      def assertMultiLineEqual(

      self, first, second, msg=None)

      @@ -9322,8 +9354,8 @@

      Static methods

      Assert that two multi-line strings are equal.

      - -
      + +
      def assertMultiLineEqual(self, first, second, msg=None):
           """Assert that two multi-line strings are equal."""
           self.assertIsInstance(first, str, 'First argument is not a string')
      @@ -9351,7 +9383,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -9366,8 +9398,8 @@

      Static methods

      as significant digits (measured from the most signficant digit).

      Objects that are equal automatically fail.

      - -
      + +
      def assertNotAlmostEqual(self, first, second, places=None, msg=None,
                                delta=None):
           """Fail if the two objects are equal as determined by their
      @@ -9405,7 +9437,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEquals(

      *args, **kwargs)

      @@ -9413,8 +9445,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -9429,7 +9461,7 @@ 

      Static methods

      -
      +

      def assertNotEqual(

      self, first, second, msg=None)

      @@ -9439,8 +9471,8 @@

      Static methods

      Fail if the two objects are equal as determined by the '!=' operator.

      - -
      + +
      def assertNotEqual(self, first, second, msg=None):
           """Fail if the two objects are equal as determined by the '!='
              operator.
      @@ -9458,7 +9490,7 @@ 

      Static methods

      -
      +

      def assertNotEquals(

      *args, **kwargs)

      @@ -9466,8 +9498,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -9482,7 +9514,7 @@ 

      Static methods

      -
      +

      def assertNotIn(

      self, member, container, msg=None)

      @@ -9491,8 +9523,8 @@

      Static methods

      Just like self.assertTrue(a not in b), but with a nicer default message.

      - -
      + +
      def assertNotIn(self, member, container, msg=None):
           """Just like self.assertTrue(a not in b), but with a nicer default message."""
           if member in container:
      @@ -9508,7 +9540,7 @@ 

      Static methods

      -
      +

      def assertNotIsInstance(

      self, obj, cls, msg=None)

      @@ -9517,8 +9549,8 @@

      Static methods

      Included for symmetry with assertIsInstance.

      - -
      + +
      def assertNotIsInstance(self, obj, cls, msg=None):
           """Included for symmetry with assertIsInstance."""
           if isinstance(obj, cls):
      @@ -9533,7 +9565,7 @@ 

      Static methods

      -
      +

      def assertNotRegex(

      self, text, unexpected_regex, msg=None)

      @@ -9542,20 +9574,19 @@

      Static methods

      Fail the test if the text matches the regular expression.

      - -
      + +
      def assertNotRegex(self, text, unexpected_regex, msg=None):
           """Fail the test if the text matches the regular expression."""
           if isinstance(unexpected_regex, (str, bytes)):
               unexpected_regex = re.compile(unexpected_regex)
           match = unexpected_regex.search(text)
           if match:
      -        standardMsg = 'Regex matched: %r matches %r in %r' % (
      -            text[match.start() : match.end()],
      -            unexpected_regex.pattern,
      -            text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex matched"
      +        msg = '%s: %r matches %r in %r' % (msg,
      +                                           text[match.start():match.end()],
      +                                           unexpected_regex.pattern,
      +                                           text)
               raise self.failureException(msg)
       
      @@ -9566,44 +9597,20 @@

      Static methods

      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - - -
      -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +
      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -9621,16 +9628,16 @@ 

      Static methods

      self.assertEqual(the_exception.error_code, 3)
      - -
      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +  
      +  
      +
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -9644,8 +9651,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -9655,8 +9662,8 @@

      Static methods

      -
      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +
      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -9667,27 +9674,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -9697,7 +9707,7 @@

      Static methods

      -
      +

      def assertRaisesRegexp(

      *args, **kwargs)

      @@ -9705,8 +9715,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -9721,7 +9731,7 @@ 

      Static methods

      -
      +

      def assertRegex(

      self, text, expected_regex, msg=None)

      @@ -9730,18 +9740,16 @@

      Static methods

      Fail the test unless the text matches the regular expression.

      - -
      + +
      def assertRegex(self, text, expected_regex, msg=None):
           """Fail the test unless the text matches the regular expression."""
           if isinstance(expected_regex, (str, bytes)):
               assert expected_regex, "expected_regex must not be empty."
               expected_regex = re.compile(expected_regex)
           if not expected_regex.search(text):
      -        standardMsg = "Regex didn't match: %r not found in %r" % (
      -            expected_regex.pattern, text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex didn't match"
      +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
               raise self.failureException(msg)
       
      @@ -9752,7 +9760,7 @@

      Static methods

      -
      +

      def assertRegexpMatches(

      *args, **kwargs)

      @@ -9760,8 +9768,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -9776,7 +9784,7 @@ 

      Static methods

      -
      +

      def assertSequenceEqual(

      self, seq1, seq2, msg=None, seq_type=None)

      @@ -9794,8 +9802,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
           """An equality assertion for ordered sequences (like lists and tuples).
           For the purposes of this function, a valid ordered sequence type is one
      @@ -9892,7 +9900,7 @@ 

      Static methods

      -
      +

      def assertSetEqual(

      self, set1, set2, msg=None)

      @@ -9909,8 +9917,8 @@

      Static methods

      is optimized for sets specifically (parameters must support a difference method).

      - -
      + +
      def assertSetEqual(self, set1, set2, msg=None):
           """A set-specific equality assertion.
           Args:
      @@ -9956,7 +9964,7 @@ 

      Static methods

      -
      +

      def assertTrue(

      self, expr, msg=None)

      @@ -9965,8 +9973,8 @@

      Static methods

      Check that the expression is true.

      - -
      + +
      def assertTrue(self, expr, msg=None):
           """Check that the expression is true."""
           if not expr:
      @@ -9981,7 +9989,7 @@ 

      Static methods

      -
      +

      def assertTupleEqual(

      self, tuple1, tuple2, msg=None)

      @@ -9995,8 +10003,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertTupleEqual(self, tuple1, tuple2, msg=None):
           """A tuple-specific equality assertion.
           Args:
      @@ -10015,20 +10023,20 @@ 

      Static methods

      -
      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +
      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -10048,16 +10056,16 @@ 

      Static methods

      self.assertEqual(the_warning.some_attribute, 147)
      - -
      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +  
      +  
      +
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -10073,8 +10081,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -10084,8 +10092,8 @@

      Static methods

      -
      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +
      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -10099,15 +10107,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -10116,13 +10125,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -10132,7 +10143,7 @@

      Static methods

      -
      +

      def assert_(

      *args, **kwargs)

      @@ -10140,8 +10151,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -10156,7 +10167,7 @@ 

      Static methods

      -
      +

      def countTestCases(

      self)

      @@ -10164,8 +10175,8 @@

      Static methods

      - -
      + +
      def countTestCases(self):
           return 1
       
      @@ -10177,7 +10188,7 @@

      Static methods

      -
      +

      def debug(

      self)

      @@ -10186,8 +10197,8 @@

      Static methods

      Run the test without collecting errors in a TestResult

      - -
      + +
      def debug(self):
           """Run the test without collecting errors in a TestResult"""
           self.setUp()
      @@ -10205,7 +10216,7 @@ 

      Static methods

      -
      +

      def defaultTestResult(

      self)

      @@ -10213,8 +10224,8 @@

      Static methods

      - -
      + +
      def defaultTestResult(self):
           return result.TestResult()
       
      @@ -10226,7 +10237,7 @@

      Static methods

      -
      +

      def doCleanups(

      self)

      @@ -10236,8 +10247,8 @@

      Static methods

      Execute all cleanup functions. Normally called for you after tearDown.

      - -
      + +
      def doCleanups(self):
           """Execute all cleanup functions. Normally called for you after
           tearDown."""
      @@ -10258,7 +10269,7 @@ 

      Static methods

      -
      +

      def fail(

      self, msg=None)

      @@ -10267,8 +10278,8 @@

      Static methods

      Fail immediately, with the given message.

      - -
      + +
      def fail(self, msg=None):
           """Fail immediately, with the given message."""
           raise self.failureException(msg)
      @@ -10281,7 +10292,7 @@ 

      Static methods

      -
      +

      def failIf(

      *args, **kwargs)

      @@ -10289,8 +10300,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -10305,7 +10316,7 @@ 

      Static methods

      -
      +

      def failIfAlmostEqual(

      *args, **kwargs)

      @@ -10313,8 +10324,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -10329,7 +10340,7 @@ 

      Static methods

      -
      +

      def failIfEqual(

      *args, **kwargs)

      @@ -10337,8 +10348,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -10353,7 +10364,7 @@ 

      Static methods

      -
      +

      def failUnless(

      *args, **kwargs)

      @@ -10361,8 +10372,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -10377,7 +10388,7 @@ 

      Static methods

      -
      +

      def failUnlessAlmostEqual(

      *args, **kwargs)

      @@ -10385,8 +10396,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -10401,7 +10412,7 @@ 

      Static methods

      -
      +

      def failUnlessEqual(

      *args, **kwargs)

      @@ -10409,8 +10420,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -10425,7 +10436,7 @@ 

      Static methods

      -
      +

      def failUnlessRaises(

      *args, **kwargs)

      @@ -10433,8 +10444,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -10449,7 +10460,7 @@ 

      Static methods

      -
      +

      def id(

      self)

      @@ -10457,8 +10468,8 @@

      Static methods

      - -
      + +
      def id(self):
           return "%s.%s" % (strclass(self.__class__), self._testMethodName)
       
      @@ -10470,7 +10481,7 @@

      Static methods

      -
      +

      def run(

      self, result=None)

      @@ -10478,8 +10489,8 @@

      Static methods

      - -
      + +
      def run(self, result=None):
           orig_result = result
           if result is None:
      @@ -10551,26 +10562,32 @@ 

      Static methods

      -
      +

      def setUp(

      self)

      -

      Hook method for setting up the test fixture before exercising it.

      - -
      + +
      def setUp(self):
      -    data = {"Alice": {"email": 'alice@gmail.com',
      -                      "type": 'author',
      -                      "loc": 'Waterloo',
      -                      "books": ['BookA', 'BookB']},
      -            "Bobby": {"email": 'bobby@gmail.com',
      +    data = {"Bob": {"author": 'Bob',
      +                    "email": 'bob@gmail.com',
      +                    "type": 'author',
      +                    "loc": 'Waterloo',
      +                    "books": ['BookA', 'BookB']},
      +            "Bobby": {"author": 'Bobby',
      +                      "email": 'bobby@gmail.com',
                             "type": 'author',
                             "loc": 'Kitchener',
      -                      "books": ['BookC', 'BookD']}}
      +                      "books": ['BookC', 'BookD']},
      +            "Robert": {"author": 'Robert',
      +                       "email": 'robby@gmail.com',
      +                       "type": 'author',
      +                       "loc": 'Kitchener',
      +                       "books": ['BookC', 'BookD']}}
           self.log = gitnet.Log(data)
       
      @@ -10581,7 +10598,7 @@

      Static methods

      -
      +

      def shortDescription(

      self)

      @@ -10593,8 +10610,8 @@

      Static methods

      The default implementation of this method returns the first line of the specified test method's docstring.

      - -
      + +
      def shortDescription(self):
           """Returns a one-line description of the test, or None if no
           description has been provided.
      @@ -10612,7 +10629,7 @@ 

      Static methods

      -
      +

      def skipTest(

      self, reason)

      @@ -10621,8 +10638,8 @@

      Static methods

      Skip this test.

      - -
      + +
      def skipTest(self, reason):
           """Skip this test."""
           raise SkipTest(reason)
      @@ -10635,7 +10652,7 @@ 

      Static methods

      -
      +

      def subTest(

      *args, **kwds)

      @@ -10648,8 +10665,8 @@

      Static methods

      case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed.

      - -
      + +
      @contextlib.contextmanager
       def subTest(self, msg=None, **params):
           """Return a context manager that will return the enclosed block
      @@ -10689,7 +10706,7 @@ 

      Static methods

      -
      +

      def tearDown(

      self)

      @@ -10698,8 +10715,8 @@

      Static methods

      Hook method for deconstructing the test fixture after testing it.

      - -
      + +
      def tearDown(self):
           "Hook method for deconstructing the test fixture after testing it."
           pass
      @@ -10712,24 +10729,19 @@ 

      Static methods

      -
      -

      def test_attr(

      self)

      +
      +

      def test_list_length(

      self)

      - -
      -
      def test_attr(self):
      -    with patch("sys.stdin", StringIO("q")), patch("sys.stdout", new_callable=StringIO) as fake_out:
      -        self.log.browse()
      -        self.assertTrue("Waterloo" in fake_out.getvalue() and "Kitchener" not in fake_out.getvalue() or
      -                        "Kitchener" in fake_out.getvalue() and "Waterloo" not in fake_out.getvalue())
      -        self.assertIn("author", fake_out.getvalue())
      -        self.assertTrue("BookA\nBookB" in fake_out.getvalue() and "BookC\nBookD" not in fake_out.getvalue() or
      -                        "BookC\nBookD" in fake_out.getvalue() and "BookA\nBookB" not in fake_out.getvalue())
      +  
      +  
      +
      def test_list_length(self):
      +    temp = len(self.log.author_email_list())
      +    self.assertEqual(temp, 263)
       
      @@ -10739,23 +10751,43 @@

      Static methods

      -
      -

      def test_quit(

      self)

      +
      +

      def test_list_type(

      self)

      -

      Is the output as expected upon the input of q?

      - -
      -
      def test_quit(self):
      -    """Is the output as expected upon the input of q?"""
      -    with patch("sys.stdin", StringIO("q")), patch("sys.stdout", new_callable=StringIO) as fake_out:
      -        self.log.browse()
      -        self.assertTrue("-- Alice --" in fake_out.getvalue() and "-- Bobby --" not in fake_out.getvalue() or
      -                        "-- Bobby --" in fake_out.getvalue() and "-- Alice --" not in fake_out.getvalue())
      +  
      +  
      +
      def test_list_type(self):
      +    temp = self.log.author_email_list()
      +    self.assertIsInstance(temp, str)
      +
      + +
      +
      + +
      + + +
      +
      +

      def test_output(

      self)

      +
      + + + + +
      + +
      +
      def test_output(self):
      +    temp = str(self.log.author_email_list())
      +    self.assertIn('robby@gmail.com   Robert', temp)
      +    self.assertIn('bob@gmail.com   Bob', temp)
      +    self.assertIn('bobby@gmail.com   Bobby', temp)
       
      @@ -10766,7 +10798,7 @@

      Static methods

      Methods

      -
      +

      def setUpClass(

      cls)

      @@ -10775,8 +10807,8 @@

      Methods

      Hook method for setting up class fixture before running tests in the class.

      - -
      + +
      @classmethod
       def setUpClass(cls):
           "Hook method for setting up class fixture before running tests in the class."
      @@ -10789,7 +10821,7 @@ 

      Methods

      -
      +

      def tearDownClass(

      cls)

      @@ -10798,8 +10830,8 @@

      Methods

      Hook method for deconstructing the class fixture after running all tests in the class.

      - -
      + +
      @classmethod
       def tearDownClass(cls):
           "Hook method for deconstructing the class fixture after running all tests in the class."
      @@ -10814,67 +10846,39 @@ 

      Methods

      -

      class DataFrameTests

      +

      class BrowseTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      - -
      -
      class DataFrameTests(unittest.TestCase):
      +  
      +  
      +
      class BrowseTests(unittest.TestCase):
           def setUp(self):
      -        # Creating a log object
               data = {"Alice": {"email": 'alice@gmail.com',
                                 "type": 'author',
                                 "loc": 'Waterloo',
      -                          "books": ['BookA', 'BookB'],
      -                          "stars": [4, 5]},
      +                          "books": ['BookA', 'BookB']},
                       "Bobby": {"email": 'bobby@gmail.com',
                                 "type": 'author',
                                 "loc": 'Kitchener',
      -                          "books": ['BookC', 'BookD'],
      -                          "stars": [4, 4]}}
      +                          "books": ['BookC', 'BookD']}}
               self.log = gitnet.Log(data)
       
      -        self.df = self.log.df()
      -
      -    def test_basic(self):
      -        """Check that a dataframe is produced"""
      -        self.assertIsInstance(self.df, pd.DataFrame)
      -
      -    def test_values(self):
      -        columns = ['books', 'email', 'loc', 'stars', 'type']
      -        index = ['Alice', 'Bobby']
      -        data = [[['BookA', 'BookB'], 'alice@gmail.com', 'Waterloo', [4, 5], 'author'],
      -                [['BookC', 'BookD'], 'bobby@gmail.com', 'Kitchener', [4, 4], 'author']]
      +    def test_quit(self):
      +        """Is the output as expected upon the input of q?"""
      +        with patch("sys.stdin", StringIO("q")), patch("sys.stdout", new_callable=StringIO) as fake_out:
      +            self.log.browse()
      +            self.assertTrue("-- Alice --" in fake_out.getvalue() and "-- Bobby --" not in fake_out.getvalue() or
      +                            "-- Bobby --" in fake_out.getvalue() and "-- Alice --" not in fake_out.getvalue())
       
      -        expected_df = pd.DataFrame(columns=columns, index=index, data=data)
      -        # Checking the created dataframe matches the expected dataframe
      -        assert_frame_equal(expected_df, self.df)
      +    def test_attr(self):
      +        with patch("sys.stdin", StringIO("q")), patch("sys.stdout", new_callable=StringIO) as fake_out:
      +            self.log.browse()
      +            self.assertTrue("Waterloo" in fake_out.getvalue() and "Kitchener" not in fake_out.getvalue() or
      +                            "Kitchener" in fake_out.getvalue() and "Waterloo" not in fake_out.getvalue())
      +            self.assertIn("author", fake_out.getvalue())
      +            self.assertTrue("BookA\nBookB" in fake_out.getvalue() and "BookC\nBookD" not in fake_out.getvalue() or
      +                            "BookC\nBookD" in fake_out.getvalue() and "BookA\nBookB" not in fake_out.getvalue())
       
      @@ -10884,13 +10888,13 @@

      Methods

      Ancestors (in MRO)

      Class variables

      -

      var failureException

      +

      var failureException

      @@ -10900,7 +10904,7 @@

      Class variables

      -

      var longMessage

      +

      var longMessage

      @@ -10910,7 +10914,7 @@

      Class variables

      -

      var maxDiff

      +

      var maxDiff

      @@ -10922,7 +10926,7 @@

      Class variables

      Static methods

      -
      +

      def __init__(

      self, methodName='runTest')

      @@ -10933,8 +10937,8 @@

      Static methods

      method when executed. Raises a ValueError if the instance does not have a method with the specified name.

      - -
      + +
      def __init__(self, methodName='runTest'):
           """Create an instance of the class that will use the named test
              method when executed. Raises a ValueError if the instance does
      @@ -10974,7 +10978,7 @@ 

      Static methods

      -
      +

      def addCleanup(

      self, function, *args, **kwargs)

      @@ -10986,8 +10990,8 @@

      Static methods

      called after tearDown on test failure or success.

      Cleanup items are called even if setUp fails (unlike tearDown).

      - -
      + +
      def addCleanup(self, function, *args, **kwargs):
           """Add a function, with arguments, to be called when the test is
           completed. Functions added are called on a LIFO basis and are
      @@ -11003,7 +11007,7 @@ 

      Static methods

      -
      +

      def addTypeEqualityFunc(

      self, typeobj, function)

      @@ -11020,8 +11024,8 @@

      Static methods

      msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.

      - -
      + +
      def addTypeEqualityFunc(self, typeobj, function):
           """Add a type specific assertEqual style function to compare a type.
           This method is for use by TestCase subclasses that need to register
      @@ -11043,7 +11047,7 @@ 

      Static methods

      -
      +

      def assertAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -11059,8 +11063,8 @@

      Static methods

      If the two objects compare equal then they will automatically compare almost equal.

      - -
      + +
      def assertAlmostEqual(self, first, second, places=None, msg=None,
                             delta=None):
           """Fail if the two objects are unequal as determined by their
      @@ -11102,7 +11106,7 @@ 

      Static methods

      -
      +

      def assertAlmostEquals(

      *args, **kwargs)

      @@ -11110,8 +11114,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -11126,7 +11130,7 @@ 

      Static methods

      -
      +

      def assertCountEqual(

      self, first, second, msg=None)

      @@ -11145,8 +11149,8 @@

      Static methods

      - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

      - -
      + +
      def assertCountEqual(self, first, second, msg=None):
           """An unordered sequence comparison asserting that the same elements,
           regardless of order.  If the same element occurs more than once,
      @@ -11184,7 +11188,7 @@ 

      Static methods

      -
      +

      def assertDictContainsSubset(

      self, subset, dictionary, msg=None)

      @@ -11193,8 +11197,8 @@

      Static methods

      Checks whether dictionary is a superset of subset.

      - -
      + +
      def assertDictContainsSubset(self, subset, dictionary, msg=None):
           """Checks whether dictionary is a superset of subset."""
           warnings.warn('assertDictContainsSubset is deprecated',
      @@ -11228,7 +11232,7 @@ 

      Static methods

      -
      +

      def assertDictEqual(

      self, d1, d2, msg=None)

      @@ -11236,8 +11240,8 @@

      Static methods

      - -
      + +
      def assertDictEqual(self, d1, d2, msg=None):
           self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
           self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
      @@ -11257,7 +11261,7 @@ 

      Static methods

      -
      +

      def assertEqual(

      self, first, second, msg=None)

      @@ -11267,8 +11271,8 @@

      Static methods

      Fail if the two objects are unequal as determined by the '==' operator.

      - -
      + +
      def assertEqual(self, first, second, msg=None):
           """Fail if the two objects are unequal as determined by the '=='
              operator.
      @@ -11284,7 +11288,7 @@ 

      Static methods

      -
      +

      def assertEquals(

      *args, **kwargs)

      @@ -11292,8 +11296,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -11308,7 +11312,7 @@ 

      Static methods

      -
      +

      def assertFalse(

      self, expr, msg=None)

      @@ -11317,8 +11321,8 @@

      Static methods

      Check that the expression is false.

      - -
      + +
      def assertFalse(self, expr, msg=None):
           """Check that the expression is false."""
           if expr:
      @@ -11333,7 +11337,7 @@ 

      Static methods

      -
      +

      def assertGreater(

      self, a, b, msg=None)

      @@ -11342,8 +11346,8 @@

      Static methods

      Just like self.assertTrue(a > b), but with a nicer default message.

      - -
      + +
      def assertGreater(self, a, b, msg=None):
           """Just like self.assertTrue(a > b), but with a nicer default message."""
           if not a > b:
      @@ -11358,7 +11362,7 @@ 

      Static methods

      -
      +

      def assertGreaterEqual(

      self, a, b, msg=None)

      @@ -11367,8 +11371,8 @@

      Static methods

      Just like self.assertTrue(a >= b), but with a nicer default message.

      - -
      + +
      def assertGreaterEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a >= b), but with a nicer default message."""
           if not a >= b:
      @@ -11383,7 +11387,7 @@ 

      Static methods

      -
      +

      def assertIn(

      self, member, container, msg=None)

      @@ -11392,8 +11396,8 @@

      Static methods

      Just like self.assertTrue(a in b), but with a nicer default message.

      - -
      + +
      def assertIn(self, member, container, msg=None):
           """Just like self.assertTrue(a in b), but with a nicer default message."""
           if member not in container:
      @@ -11409,7 +11413,7 @@ 

      Static methods

      -
      +

      def assertIs(

      self, expr1, expr2, msg=None)

      @@ -11418,8 +11422,8 @@

      Static methods

      Just like self.assertTrue(a is b), but with a nicer default message.

      - -
      + +
      def assertIs(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is b), but with a nicer default message."""
           if expr1 is not expr2:
      @@ -11435,7 +11439,7 @@ 

      Static methods

      -
      +

      def assertIsInstance(

      self, obj, cls, msg=None)

      @@ -11445,8 +11449,8 @@

      Static methods

      Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

      - -
      + +
      def assertIsInstance(self, obj, cls, msg=None):
           """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
           default message."""
      @@ -11462,7 +11466,7 @@ 

      Static methods

      -
      +

      def assertIsNone(

      self, obj, msg=None)

      @@ -11471,8 +11475,8 @@

      Static methods

      Same as self.assertTrue(obj is None), with a nicer default message.

      - -
      + +
      def assertIsNone(self, obj, msg=None):
           """Same as self.assertTrue(obj is None), with a nicer default message."""
           if obj is not None:
      @@ -11487,7 +11491,7 @@ 

      Static methods

      -
      +

      def assertIsNot(

      self, expr1, expr2, msg=None)

      @@ -11496,8 +11500,8 @@

      Static methods

      Just like self.assertTrue(a is not b), but with a nicer default message.

      - -
      + +
      def assertIsNot(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is not b), but with a nicer default message."""
           if expr1 is expr2:
      @@ -11512,7 +11516,7 @@ 

      Static methods

      -
      +

      def assertIsNotNone(

      self, obj, msg=None)

      @@ -11521,8 +11525,8 @@

      Static methods

      Included for symmetry with assertIsNone.

      - -
      + +
      def assertIsNotNone(self, obj, msg=None):
           """Included for symmetry with assertIsNone."""
           if obj is None:
      @@ -11537,7 +11541,7 @@ 

      Static methods

      -
      +

      def assertLess(

      self, a, b, msg=None)

      @@ -11546,8 +11550,8 @@

      Static methods

      Just like self.assertTrue(a < b), but with a nicer default message.

      - -
      + +
      def assertLess(self, a, b, msg=None):
           """Just like self.assertTrue(a < b), but with a nicer default message."""
           if not a < b:
      @@ -11562,7 +11566,7 @@ 

      Static methods

      -
      +

      def assertLessEqual(

      self, a, b, msg=None)

      @@ -11571,8 +11575,8 @@

      Static methods

      Just like self.assertTrue(a <= b), but with a nicer default message.

      - -
      + +
      def assertLessEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a <= b), but with a nicer default message."""
           if not a <= b:
      @@ -11587,7 +11591,7 @@ 

      Static methods

      -
      +

      def assertListEqual(

      self, list1, list2, msg=None)

      @@ -11601,8 +11605,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertListEqual(self, list1, list2, msg=None):
           """A list-specific equality assertion.
           Args:
      @@ -11621,7 +11625,7 @@ 

      Static methods

      -
      +

      def assertLogs(

      self, logger=None, level=None)

      @@ -11645,8 +11649,8 @@

      Static methods

      'ERROR:foo.bar:second message'])
      - -
      + +
      def assertLogs(self, logger=None, level=None):
           """Fail unless a log message of level *level* or higher is emitted
           on *logger_name* or its children.  If omitted, *level* defaults to
      @@ -11674,7 +11678,7 @@ 

      Static methods

      -
      +

      def assertMultiLineEqual(

      self, first, second, msg=None)

      @@ -11683,8 +11687,8 @@

      Static methods

      Assert that two multi-line strings are equal.

      - -
      + +
      def assertMultiLineEqual(self, first, second, msg=None):
           """Assert that two multi-line strings are equal."""
           self.assertIsInstance(first, str, 'First argument is not a string')
      @@ -11712,7 +11716,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -11727,8 +11731,8 @@

      Static methods

      as significant digits (measured from the most signficant digit).

      Objects that are equal automatically fail.

      - -
      + +
      def assertNotAlmostEqual(self, first, second, places=None, msg=None,
                                delta=None):
           """Fail if the two objects are equal as determined by their
      @@ -11766,7 +11770,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEquals(

      *args, **kwargs)

      @@ -11774,8 +11778,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -11790,7 +11794,7 @@ 

      Static methods

      -
      +

      def assertNotEqual(

      self, first, second, msg=None)

      @@ -11800,8 +11804,8 @@

      Static methods

      Fail if the two objects are equal as determined by the '!=' operator.

      - -
      + +
      def assertNotEqual(self, first, second, msg=None):
           """Fail if the two objects are equal as determined by the '!='
              operator.
      @@ -11819,7 +11823,7 @@ 

      Static methods

      -
      +

      def assertNotEquals(

      *args, **kwargs)

      @@ -11827,8 +11831,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -11843,7 +11847,7 @@ 

      Static methods

      -
      +

      def assertNotIn(

      self, member, container, msg=None)

      @@ -11852,8 +11856,8 @@

      Static methods

      Just like self.assertTrue(a not in b), but with a nicer default message.

      - -
      + +
      def assertNotIn(self, member, container, msg=None):
           """Just like self.assertTrue(a not in b), but with a nicer default message."""
           if member in container:
      @@ -11869,7 +11873,7 @@ 

      Static methods

      -
      +

      def assertNotIsInstance(

      self, obj, cls, msg=None)

      @@ -11878,8 +11882,8 @@

      Static methods

      Included for symmetry with assertIsInstance.

      - -
      + +
      def assertNotIsInstance(self, obj, cls, msg=None):
           """Included for symmetry with assertIsInstance."""
           if isinstance(obj, cls):
      @@ -11894,7 +11898,7 @@ 

      Static methods

      -
      +

      def assertNotRegex(

      self, text, unexpected_regex, msg=None)

      @@ -11903,20 +11907,19 @@

      Static methods

      Fail the test if the text matches the regular expression.

      - -
      + +
      def assertNotRegex(self, text, unexpected_regex, msg=None):
           """Fail the test if the text matches the regular expression."""
           if isinstance(unexpected_regex, (str, bytes)):
               unexpected_regex = re.compile(unexpected_regex)
           match = unexpected_regex.search(text)
           if match:
      -        standardMsg = 'Regex matched: %r matches %r in %r' % (
      -            text[match.start() : match.end()],
      -            unexpected_regex.pattern,
      -            text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex matched"
      +        msg = '%s: %r matches %r in %r' % (msg,
      +                                           text[match.start():match.end()],
      +                                           unexpected_regex.pattern,
      +                                           text)
               raise self.failureException(msg)
       
      @@ -11927,44 +11930,20 @@

      Static methods

      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - - -
      -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +
      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -11982,16 +11961,16 @@ 

      Static methods

      self.assertEqual(the_exception.error_code, 3)
      - -
      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +  
      +  
      +
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -12005,8 +11984,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -12016,8 +11995,8 @@

      Static methods

      -
      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +
      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -12028,27 +12007,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -12058,7 +12040,7 @@

      Static methods

      -
      +

      def assertRaisesRegexp(

      *args, **kwargs)

      @@ -12066,8 +12048,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12082,7 +12064,7 @@ 

      Static methods

      -
      +

      def assertRegex(

      self, text, expected_regex, msg=None)

      @@ -12091,18 +12073,16 @@

      Static methods

      Fail the test unless the text matches the regular expression.

      - -
      + +
      def assertRegex(self, text, expected_regex, msg=None):
           """Fail the test unless the text matches the regular expression."""
           if isinstance(expected_regex, (str, bytes)):
               assert expected_regex, "expected_regex must not be empty."
               expected_regex = re.compile(expected_regex)
           if not expected_regex.search(text):
      -        standardMsg = "Regex didn't match: %r not found in %r" % (
      -            expected_regex.pattern, text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex didn't match"
      +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
               raise self.failureException(msg)
       
      @@ -12113,7 +12093,7 @@

      Static methods

      -
      +

      def assertRegexpMatches(

      *args, **kwargs)

      @@ -12121,8 +12101,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12137,7 +12117,7 @@ 

      Static methods

      -
      +

      def assertSequenceEqual(

      self, seq1, seq2, msg=None, seq_type=None)

      @@ -12155,8 +12135,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
           """An equality assertion for ordered sequences (like lists and tuples).
           For the purposes of this function, a valid ordered sequence type is one
      @@ -12253,7 +12233,7 @@ 

      Static methods

      -
      +

      def assertSetEqual(

      self, set1, set2, msg=None)

      @@ -12270,8 +12250,8 @@

      Static methods

      is optimized for sets specifically (parameters must support a difference method).

      - -
      + +
      def assertSetEqual(self, set1, set2, msg=None):
           """A set-specific equality assertion.
           Args:
      @@ -12317,7 +12297,7 @@ 

      Static methods

      -
      +

      def assertTrue(

      self, expr, msg=None)

      @@ -12326,8 +12306,8 @@

      Static methods

      Check that the expression is true.

      - -
      + +
      def assertTrue(self, expr, msg=None):
           """Check that the expression is true."""
           if not expr:
      @@ -12342,7 +12322,7 @@ 

      Static methods

      -
      +

      def assertTupleEqual(

      self, tuple1, tuple2, msg=None)

      @@ -12356,8 +12336,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertTupleEqual(self, tuple1, tuple2, msg=None):
           """A tuple-specific equality assertion.
           Args:
      @@ -12376,20 +12356,20 @@ 

      Static methods

      -
      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +
      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -12409,16 +12389,16 @@ 

      Static methods

      self.assertEqual(the_warning.some_attribute, 147)
      - -
      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +  
      +  
      +
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -12434,8 +12414,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -12445,8 +12425,8 @@

      Static methods

      -
      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +
      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -12460,15 +12440,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -12477,13 +12458,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -12493,7 +12476,7 @@

      Static methods

      -
      +

      def assert_(

      *args, **kwargs)

      @@ -12501,8 +12484,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12517,7 +12500,7 @@ 

      Static methods

      -
      +

      def countTestCases(

      self)

      @@ -12525,8 +12508,8 @@

      Static methods

      - -
      + +
      def countTestCases(self):
           return 1
       
      @@ -12538,7 +12521,7 @@

      Static methods

      -
      +

      def debug(

      self)

      @@ -12547,8 +12530,8 @@

      Static methods

      Run the test without collecting errors in a TestResult

      - -
      + +
      def debug(self):
           """Run the test without collecting errors in a TestResult"""
           self.setUp()
      @@ -12566,7 +12549,7 @@ 

      Static methods

      -
      +

      def defaultTestResult(

      self)

      @@ -12574,8 +12557,8 @@

      Static methods

      - -
      + +
      def defaultTestResult(self):
           return result.TestResult()
       
      @@ -12587,7 +12570,7 @@

      Static methods

      -
      +

      def doCleanups(

      self)

      @@ -12597,8 +12580,8 @@

      Static methods

      Execute all cleanup functions. Normally called for you after tearDown.

      - -
      + +
      def doCleanups(self):
           """Execute all cleanup functions. Normally called for you after
           tearDown."""
      @@ -12619,7 +12602,7 @@ 

      Static methods

      -
      +

      def fail(

      self, msg=None)

      @@ -12628,8 +12611,8 @@

      Static methods

      Fail immediately, with the given message.

      - -
      + +
      def fail(self, msg=None):
           """Fail immediately, with the given message."""
           raise self.failureException(msg)
      @@ -12642,7 +12625,7 @@ 

      Static methods

      -
      +

      def failIf(

      *args, **kwargs)

      @@ -12650,8 +12633,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12666,7 +12649,7 @@ 

      Static methods

      -
      +

      def failIfAlmostEqual(

      *args, **kwargs)

      @@ -12674,8 +12657,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12690,7 +12673,7 @@ 

      Static methods

      -
      +

      def failIfEqual(

      *args, **kwargs)

      @@ -12698,8 +12681,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12714,7 +12697,7 @@ 

      Static methods

      -
      +

      def failUnless(

      *args, **kwargs)

      @@ -12722,8 +12705,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12738,7 +12721,7 @@ 

      Static methods

      -
      +

      def failUnlessAlmostEqual(

      *args, **kwargs)

      @@ -12746,8 +12729,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12762,7 +12745,7 @@ 

      Static methods

      -
      +

      def failUnlessEqual(

      *args, **kwargs)

      @@ -12770,8 +12753,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12786,7 +12769,7 @@ 

      Static methods

      -
      +

      def failUnlessRaises(

      *args, **kwargs)

      @@ -12794,8 +12777,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -12810,7 +12793,7 @@ 

      Static methods

      -
      +

      def id(

      self)

      @@ -12818,8 +12801,8 @@

      Static methods

      - -
      + +
      def id(self):
           return "%s.%s" % (strclass(self.__class__), self._testMethodName)
       
      @@ -12831,7 +12814,7 @@

      Static methods

      -
      +

      def run(

      self, result=None)

      @@ -12839,8 +12822,8 @@

      Static methods

      - -
      + +
      def run(self, result=None):
           orig_result = result
           if result is None:
      @@ -12912,31 +12895,26 @@ 

      Static methods

      -
      +

      def setUp(

      self)

      -

      Hook method for setting up the test fixture before exercising it.

      - -
      + +
      def setUp(self):
      -    # Creating a log object
           data = {"Alice": {"email": 'alice@gmail.com',
                             "type": 'author',
                             "loc": 'Waterloo',
      -                      "books": ['BookA', 'BookB'],
      -                      "stars": [4, 5]},
      +                      "books": ['BookA', 'BookB']},
                   "Bobby": {"email": 'bobby@gmail.com',
                             "type": 'author',
                             "loc": 'Kitchener',
      -                      "books": ['BookC', 'BookD'],
      -                      "stars": [4, 4]}}
      +                      "books": ['BookC', 'BookD']}}
           self.log = gitnet.Log(data)
      -    self.df = self.log.df()
       
      @@ -12946,7 +12924,7 @@

      Static methods

      -
      +

      def shortDescription(

      self)

      @@ -12958,8 +12936,8 @@

      Static methods

      The default implementation of this method returns the first line of the specified test method's docstring.

      - -
      + +
      def shortDescription(self):
           """Returns a one-line description of the test, or None if no
           description has been provided.
      @@ -12977,7 +12955,7 @@ 

      Static methods

      -
      +

      def skipTest(

      self, reason)

      @@ -12986,8 +12964,8 @@

      Static methods

      Skip this test.

      - -
      + +
      def skipTest(self, reason):
           """Skip this test."""
           raise SkipTest(reason)
      @@ -13000,7 +12978,7 @@ 

      Static methods

      -
      +

      def subTest(

      *args, **kwds)

      @@ -13013,8 +12991,8 @@

      Static methods

      case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed.

      - -
      + +
      @contextlib.contextmanager
       def subTest(self, msg=None, **params):
           """Return a context manager that will return the enclosed block
      @@ -13054,7 +13032,7 @@ 

      Static methods

      -
      +

      def tearDown(

      self)

      @@ -13063,8 +13041,8 @@

      Static methods

      Hook method for deconstructing the test fixture after testing it.

      - -
      + +
      def tearDown(self):
           "Hook method for deconstructing the test fixture after testing it."
           pass
      @@ -13077,20 +13055,24 @@ 

      Static methods

      -
      -

      def test_basic(

      self)

      +
      +

      def test_attr(

      self)

      -

      Check that a dataframe is produced

      - -
      -
      def test_basic(self):
      -    """Check that a dataframe is produced"""
      -    self.assertIsInstance(self.df, pd.DataFrame)
      +  
      +  
      +
      def test_attr(self):
      +    with patch("sys.stdin", StringIO("q")), patch("sys.stdout", new_callable=StringIO) as fake_out:
      +        self.log.browse()
      +        self.assertTrue("Waterloo" in fake_out.getvalue() and "Kitchener" not in fake_out.getvalue() or
      +                        "Kitchener" in fake_out.getvalue() and "Waterloo" not in fake_out.getvalue())
      +        self.assertIn("author", fake_out.getvalue())
      +        self.assertTrue("BookA\nBookB" in fake_out.getvalue() and "BookC\nBookD" not in fake_out.getvalue() or
      +                        "BookC\nBookD" in fake_out.getvalue() and "BookA\nBookB" not in fake_out.getvalue())
       
      @@ -13100,24 +13082,23 @@

      Static methods

      -
      -

      def test_values(

      self)

      +
      +

      def test_quit(

      self)

      +

      Is the output as expected upon the input of q?

      - -
      -
      def test_values(self):
      -    columns = ['books', 'email', 'loc', 'stars', 'type']
      -    index = ['Alice', 'Bobby']
      -    data = [[['BookA', 'BookB'], 'alice@gmail.com', 'Waterloo', [4, 5], 'author'],
      -            [['BookC', 'BookD'], 'bobby@gmail.com', 'Kitchener', [4, 4], 'author']]
      -    expected_df = pd.DataFrame(columns=columns, index=index, data=data)
      -    # Checking the created dataframe matches the expected dataframe
      -    assert_frame_equal(expected_df, self.df)
      +  
      +  
      +
      def test_quit(self):
      +    """Is the output as expected upon the input of q?"""
      +    with patch("sys.stdin", StringIO("q")), patch("sys.stdout", new_callable=StringIO) as fake_out:
      +        self.log.browse()
      +        self.assertTrue("-- Alice --" in fake_out.getvalue() and "-- Bobby --" not in fake_out.getvalue() or
      +                        "-- Bobby --" in fake_out.getvalue() and "-- Alice --" not in fake_out.getvalue())
       
      @@ -13128,7 +13109,7 @@

      Static methods

      Methods

      -
      +

      def setUpClass(

      cls)

      @@ -13137,8 +13118,8 @@

      Methods

      Hook method for setting up class fixture before running tests in the class.

      - -
      + +
      @classmethod
       def setUpClass(cls):
           "Hook method for setting up class fixture before running tests in the class."
      @@ -13151,7 +13132,7 @@ 

      Methods

      -
      +

      def tearDownClass(

      cls)

      @@ -13160,8 +13141,8 @@

      Methods

      Hook method for deconstructing the class fixture after running all tests in the class.

      - -
      + +
      @classmethod
       def tearDownClass(cls):
           "Hook method for deconstructing the class fixture after running all tests in the class."
      @@ -13176,67 +13157,42 @@ 

      Methods

      -

      class DescribeTests

      +

      class DataFrameTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      - -
      -
      class DescribeTests(unittest.TestCase):
      +  
      +  
      +
      class DataFrameTests(unittest.TestCase):
           def setUp(self):
      +        # Creating a log object
               data = {"Alice": {"email": 'alice@gmail.com',
                                 "type": 'author',
      -                          "loc": 'Waterloo'},
      +                          "loc": 'Waterloo',
      +                          "books": ['BookA', 'BookB'],
      +                          "stars": [4, 5]},
                       "Bobby": {"email": 'bobby@gmail.com',
                                 "type": 'author',
      -                          "loc": 'Kitchener'}}
      +                          "loc": 'Kitchener',
      +                          "books": ['BookC', 'BookD'],
      +                          "stars": [4, 4]}}
               self.log = gitnet.Log(data)
       
      -    def test_basic(self):
      -        self.log.describe()
      -        self.assertIsNotNone(self.log.describe())
      -        self.assertIsInstance(self.log.describe(), str)
      +        self.df = self.log.df()
       
      -    def test_print(self):
      -        with patch('sys.stdout', new=StringIO()) as fake_out:
      -            self.log.describe()
      -            self.assertIn("Log containing 2 records from None created at", fake_out.getvalue())
      -            self.assertNotIn("Filter:", fake_out.getvalue())
      +    def test_basic(self):
      +        """Check that a dataframe is produced"""
      +        self.assertIsInstance(self.df, pd.DataFrame)
       
      -    def test_filter_print(self):
      -        self.log.filters = ["{} {} {} | Negate: {} | Helper: {}".format('age', '>', 10, False, None)]
      +    def test_values(self):
      +        columns = ['books', 'email', 'loc', 'stars', 'type']
      +        index = ['Alice', 'Bobby']
      +        data = [[['BookA', 'BookB'], 'alice@gmail.com', 'Waterloo', [4, 5], 'author'],
      +                [['BookC', 'BookD'], 'bobby@gmail.com', 'Kitchener', [4, 4], 'author']]
       
      -        with patch('sys.stdout', new=StringIO()) as fake_out:
      -            self.log.describe()
      -            self.assertRegex(fake_out.getvalue(),
      -                             "Log containing 2 records from None created at ....-..-.. ..:..:..\.......\.\n"
      -                             "None\n"
      -                             "Filters:\tage > 10 | Negate: False | Helper: None")
      +        expected_df = pd.DataFrame(columns=columns, index=index, data=data)
      +        # Checking the created dataframe matches the expected dataframe
      +        assert_frame_equal(expected_df, self.df)
       
      @@ -13246,13 +13202,13 @@

      Methods

      Ancestors (in MRO)

      Class variables

      -

      var failureException

      +

      var failureException

      @@ -13262,7 +13218,7 @@

      Class variables

      -

      var longMessage

      +

      var longMessage

      @@ -13272,7 +13228,7 @@

      Class variables

      -

      var maxDiff

      +

      var maxDiff

      @@ -13284,7 +13240,7 @@

      Class variables

      Static methods

      -
      +

      def __init__(

      self, methodName='runTest')

      @@ -13295,8 +13251,8 @@

      Static methods

      method when executed. Raises a ValueError if the instance does not have a method with the specified name.

      - -
      + +
      def __init__(self, methodName='runTest'):
           """Create an instance of the class that will use the named test
              method when executed. Raises a ValueError if the instance does
      @@ -13336,7 +13292,7 @@ 

      Static methods

      -
      +

      def addCleanup(

      self, function, *args, **kwargs)

      @@ -13348,8 +13304,8 @@

      Static methods

      called after tearDown on test failure or success.

      Cleanup items are called even if setUp fails (unlike tearDown).

      - -
      + +
      def addCleanup(self, function, *args, **kwargs):
           """Add a function, with arguments, to be called when the test is
           completed. Functions added are called on a LIFO basis and are
      @@ -13365,7 +13321,7 @@ 

      Static methods

      -
      +

      def addTypeEqualityFunc(

      self, typeobj, function)

      @@ -13382,8 +13338,8 @@

      Static methods

      msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.

      - -
      + +
      def addTypeEqualityFunc(self, typeobj, function):
           """Add a type specific assertEqual style function to compare a type.
           This method is for use by TestCase subclasses that need to register
      @@ -13405,7 +13361,7 @@ 

      Static methods

      -
      +

      def assertAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -13421,8 +13377,8 @@

      Static methods

      If the two objects compare equal then they will automatically compare almost equal.

      - -
      + +
      def assertAlmostEqual(self, first, second, places=None, msg=None,
                             delta=None):
           """Fail if the two objects are unequal as determined by their
      @@ -13464,7 +13420,7 @@ 

      Static methods

      -
      +

      def assertAlmostEquals(

      *args, **kwargs)

      @@ -13472,8 +13428,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -13488,7 +13444,7 @@ 

      Static methods

      -
      +

      def assertCountEqual(

      self, first, second, msg=None)

      @@ -13507,8 +13463,8 @@

      Static methods

      - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

      - -
      + +
      def assertCountEqual(self, first, second, msg=None):
           """An unordered sequence comparison asserting that the same elements,
           regardless of order.  If the same element occurs more than once,
      @@ -13546,7 +13502,7 @@ 

      Static methods

      -
      +

      def assertDictContainsSubset(

      self, subset, dictionary, msg=None)

      @@ -13555,8 +13511,8 @@

      Static methods

      Checks whether dictionary is a superset of subset.

      - -
      + +
      def assertDictContainsSubset(self, subset, dictionary, msg=None):
           """Checks whether dictionary is a superset of subset."""
           warnings.warn('assertDictContainsSubset is deprecated',
      @@ -13590,7 +13546,7 @@ 

      Static methods

      -
      +

      def assertDictEqual(

      self, d1, d2, msg=None)

      @@ -13598,8 +13554,8 @@

      Static methods

      - -
      + +
      def assertDictEqual(self, d1, d2, msg=None):
           self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
           self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
      @@ -13619,7 +13575,7 @@ 

      Static methods

      -
      +

      def assertEqual(

      self, first, second, msg=None)

      @@ -13629,8 +13585,8 @@

      Static methods

      Fail if the two objects are unequal as determined by the '==' operator.

      - -
      + +
      def assertEqual(self, first, second, msg=None):
           """Fail if the two objects are unequal as determined by the '=='
              operator.
      @@ -13646,7 +13602,7 @@ 

      Static methods

      -
      +

      def assertEquals(

      *args, **kwargs)

      @@ -13654,8 +13610,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -13670,7 +13626,7 @@ 

      Static methods

      -
      +

      def assertFalse(

      self, expr, msg=None)

      @@ -13679,8 +13635,8 @@

      Static methods

      Check that the expression is false.

      - -
      + +
      def assertFalse(self, expr, msg=None):
           """Check that the expression is false."""
           if expr:
      @@ -13695,7 +13651,7 @@ 

      Static methods

      -
      +

      def assertGreater(

      self, a, b, msg=None)

      @@ -13704,8 +13660,8 @@

      Static methods

      Just like self.assertTrue(a > b), but with a nicer default message.

      - -
      + +
      def assertGreater(self, a, b, msg=None):
           """Just like self.assertTrue(a > b), but with a nicer default message."""
           if not a > b:
      @@ -13720,7 +13676,7 @@ 

      Static methods

      -
      +

      def assertGreaterEqual(

      self, a, b, msg=None)

      @@ -13729,8 +13685,8 @@

      Static methods

      Just like self.assertTrue(a >= b), but with a nicer default message.

      - -
      + +
      def assertGreaterEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a >= b), but with a nicer default message."""
           if not a >= b:
      @@ -13745,7 +13701,7 @@ 

      Static methods

      -
      +

      def assertIn(

      self, member, container, msg=None)

      @@ -13754,8 +13710,8 @@

      Static methods

      Just like self.assertTrue(a in b), but with a nicer default message.

      - -
      + +
      def assertIn(self, member, container, msg=None):
           """Just like self.assertTrue(a in b), but with a nicer default message."""
           if member not in container:
      @@ -13771,7 +13727,7 @@ 

      Static methods

      -
      +

      def assertIs(

      self, expr1, expr2, msg=None)

      @@ -13780,8 +13736,8 @@

      Static methods

      Just like self.assertTrue(a is b), but with a nicer default message.

      - -
      + +
      def assertIs(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is b), but with a nicer default message."""
           if expr1 is not expr2:
      @@ -13797,7 +13753,7 @@ 

      Static methods

      -
      +

      def assertIsInstance(

      self, obj, cls, msg=None)

      @@ -13807,8 +13763,8 @@

      Static methods

      Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

      - -
      + +
      def assertIsInstance(self, obj, cls, msg=None):
           """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
           default message."""
      @@ -13824,7 +13780,7 @@ 

      Static methods

      -
      +

      def assertIsNone(

      self, obj, msg=None)

      @@ -13833,8 +13789,8 @@

      Static methods

      Same as self.assertTrue(obj is None), with a nicer default message.

      - -
      + +
      def assertIsNone(self, obj, msg=None):
           """Same as self.assertTrue(obj is None), with a nicer default message."""
           if obj is not None:
      @@ -13849,7 +13805,7 @@ 

      Static methods

      -
      +

      def assertIsNot(

      self, expr1, expr2, msg=None)

      @@ -13858,8 +13814,8 @@

      Static methods

      Just like self.assertTrue(a is not b), but with a nicer default message.

      - -
      + +
      def assertIsNot(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is not b), but with a nicer default message."""
           if expr1 is expr2:
      @@ -13874,7 +13830,7 @@ 

      Static methods

      -
      +

      def assertIsNotNone(

      self, obj, msg=None)

      @@ -13883,8 +13839,8 @@

      Static methods

      Included for symmetry with assertIsNone.

      - -
      + +
      def assertIsNotNone(self, obj, msg=None):
           """Included for symmetry with assertIsNone."""
           if obj is None:
      @@ -13899,7 +13855,7 @@ 

      Static methods

      -
      +

      def assertLess(

      self, a, b, msg=None)

      @@ -13908,8 +13864,8 @@

      Static methods

      Just like self.assertTrue(a < b), but with a nicer default message.

      - -
      + +
      def assertLess(self, a, b, msg=None):
           """Just like self.assertTrue(a < b), but with a nicer default message."""
           if not a < b:
      @@ -13924,7 +13880,7 @@ 

      Static methods

      -
      +

      def assertLessEqual(

      self, a, b, msg=None)

      @@ -13933,8 +13889,8 @@

      Static methods

      Just like self.assertTrue(a <= b), but with a nicer default message.

      - -
      + +
      def assertLessEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a <= b), but with a nicer default message."""
           if not a <= b:
      @@ -13949,7 +13905,7 @@ 

      Static methods

      -
      +

      def assertListEqual(

      self, list1, list2, msg=None)

      @@ -13963,8 +13919,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertListEqual(self, list1, list2, msg=None):
           """A list-specific equality assertion.
           Args:
      @@ -13983,7 +13939,7 @@ 

      Static methods

      -
      +

      def assertLogs(

      self, logger=None, level=None)

      @@ -14007,8 +13963,8 @@

      Static methods

      'ERROR:foo.bar:second message'])
      - -
      + +
      def assertLogs(self, logger=None, level=None):
           """Fail unless a log message of level *level* or higher is emitted
           on *logger_name* or its children.  If omitted, *level* defaults to
      @@ -14036,7 +13992,7 @@ 

      Static methods

      -
      +

      def assertMultiLineEqual(

      self, first, second, msg=None)

      @@ -14045,8 +14001,8 @@

      Static methods

      Assert that two multi-line strings are equal.

      - -
      + +
      def assertMultiLineEqual(self, first, second, msg=None):
           """Assert that two multi-line strings are equal."""
           self.assertIsInstance(first, str, 'First argument is not a string')
      @@ -14074,7 +14030,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -14089,8 +14045,8 @@

      Static methods

      as significant digits (measured from the most signficant digit).

      Objects that are equal automatically fail.

      - -
      + +
      def assertNotAlmostEqual(self, first, second, places=None, msg=None,
                                delta=None):
           """Fail if the two objects are equal as determined by their
      @@ -14128,7 +14084,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEquals(

      *args, **kwargs)

      @@ -14136,8 +14092,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -14152,7 +14108,7 @@ 

      Static methods

      -
      +

      def assertNotEqual(

      self, first, second, msg=None)

      @@ -14162,8 +14118,8 @@

      Static methods

      Fail if the two objects are equal as determined by the '!=' operator.

      - -
      + +
      def assertNotEqual(self, first, second, msg=None):
           """Fail if the two objects are equal as determined by the '!='
              operator.
      @@ -14181,7 +14137,7 @@ 

      Static methods

      -
      +

      def assertNotEquals(

      *args, **kwargs)

      @@ -14189,8 +14145,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -14205,7 +14161,7 @@ 

      Static methods

      -
      +

      def assertNotIn(

      self, member, container, msg=None)

      @@ -14214,8 +14170,8 @@

      Static methods

      Just like self.assertTrue(a not in b), but with a nicer default message.

      - -
      + +
      def assertNotIn(self, member, container, msg=None):
           """Just like self.assertTrue(a not in b), but with a nicer default message."""
           if member in container:
      @@ -14231,7 +14187,7 @@ 

      Static methods

      -
      +

      def assertNotIsInstance(

      self, obj, cls, msg=None)

      @@ -14240,8 +14196,8 @@

      Static methods

      Included for symmetry with assertIsInstance.

      - -
      + +
      def assertNotIsInstance(self, obj, cls, msg=None):
           """Included for symmetry with assertIsInstance."""
           if isinstance(obj, cls):
      @@ -14256,7 +14212,7 @@ 

      Static methods

      -
      +

      def assertNotRegex(

      self, text, unexpected_regex, msg=None)

      @@ -14265,20 +14221,19 @@

      Static methods

      Fail the test if the text matches the regular expression.

      - -
      + +
      def assertNotRegex(self, text, unexpected_regex, msg=None):
           """Fail the test if the text matches the regular expression."""
           if isinstance(unexpected_regex, (str, bytes)):
               unexpected_regex = re.compile(unexpected_regex)
           match = unexpected_regex.search(text)
           if match:
      -        standardMsg = 'Regex matched: %r matches %r in %r' % (
      -            text[match.start() : match.end()],
      -            unexpected_regex.pattern,
      -            text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex matched"
      +        msg = '%s: %r matches %r in %r' % (msg,
      +                                           text[match.start():match.end()],
      +                                           unexpected_regex.pattern,
      +                                           text)
               raise self.failureException(msg)
       
      @@ -14289,44 +14244,20 @@

      Static methods

      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - - -
      -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +
      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -14344,16 +14275,16 @@ 

      Static methods

      self.assertEqual(the_exception.error_code, 3)
      - -
      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +  
      +  
      +
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -14367,8 +14298,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -14378,8 +14309,8 @@

      Static methods

      -
      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +
      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -14390,27 +14321,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -14420,7 +14354,7 @@

      Static methods

      -
      +

      def assertRaisesRegexp(

      *args, **kwargs)

      @@ -14428,8 +14362,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -14444,7 +14378,7 @@ 

      Static methods

      -
      +

      def assertRegex(

      self, text, expected_regex, msg=None)

      @@ -14453,18 +14387,16 @@

      Static methods

      Fail the test unless the text matches the regular expression.

      - -
      + +
      def assertRegex(self, text, expected_regex, msg=None):
           """Fail the test unless the text matches the regular expression."""
           if isinstance(expected_regex, (str, bytes)):
               assert expected_regex, "expected_regex must not be empty."
               expected_regex = re.compile(expected_regex)
           if not expected_regex.search(text):
      -        standardMsg = "Regex didn't match: %r not found in %r" % (
      -            expected_regex.pattern, text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex didn't match"
      +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
               raise self.failureException(msg)
       
      @@ -14475,7 +14407,7 @@

      Static methods

      -
      +

      def assertRegexpMatches(

      *args, **kwargs)

      @@ -14483,8 +14415,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -14499,7 +14431,7 @@ 

      Static methods

      -
      +

      def assertSequenceEqual(

      self, seq1, seq2, msg=None, seq_type=None)

      @@ -14517,8 +14449,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
           """An equality assertion for ordered sequences (like lists and tuples).
           For the purposes of this function, a valid ordered sequence type is one
      @@ -14615,7 +14547,7 @@ 

      Static methods

      -
      +

      def assertSetEqual(

      self, set1, set2, msg=None)

      @@ -14632,8 +14564,8 @@

      Static methods

      is optimized for sets specifically (parameters must support a difference method).

      - -
      + +
      def assertSetEqual(self, set1, set2, msg=None):
           """A set-specific equality assertion.
           Args:
      @@ -14679,7 +14611,7 @@ 

      Static methods

      -
      +

      def assertTrue(

      self, expr, msg=None)

      @@ -14688,8 +14620,8 @@

      Static methods

      Check that the expression is true.

      - -
      + +
      def assertTrue(self, expr, msg=None):
           """Check that the expression is true."""
           if not expr:
      @@ -14704,7 +14636,7 @@ 

      Static methods

      -
      +

      def assertTupleEqual(

      self, tuple1, tuple2, msg=None)

      @@ -14718,8 +14650,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertTupleEqual(self, tuple1, tuple2, msg=None):
           """A tuple-specific equality assertion.
           Args:
      @@ -14738,20 +14670,20 @@ 

      Static methods

      -
      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +
      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -14771,16 +14703,16 @@ 

      Static methods

      self.assertEqual(the_warning.some_attribute, 147)
      - -
      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +  
      +  
      +
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -14796,8 +14728,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -14807,8 +14739,8 @@

      Static methods

      -
      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +
      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -14822,15 +14754,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -14839,13 +14772,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -14855,7 +14790,7 @@

      Static methods

      -
      +

      def assert_(

      *args, **kwargs)

      @@ -14863,8 +14798,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -14879,7 +14814,7 @@ 

      Static methods

      -
      +

      def countTestCases(

      self)

      @@ -14887,8 +14822,8 @@

      Static methods

      - -
      + +
      def countTestCases(self):
           return 1
       
      @@ -14900,7 +14835,7 @@

      Static methods

      -
      +

      def debug(

      self)

      @@ -14909,8 +14844,8 @@

      Static methods

      Run the test without collecting errors in a TestResult

      - -
      + +
      def debug(self):
           """Run the test without collecting errors in a TestResult"""
           self.setUp()
      @@ -14928,7 +14863,7 @@ 

      Static methods

      -
      +

      def defaultTestResult(

      self)

      @@ -14936,8 +14871,8 @@

      Static methods

      - -
      + +
      def defaultTestResult(self):
           return result.TestResult()
       
      @@ -14949,7 +14884,7 @@

      Static methods

      -
      +

      def doCleanups(

      self)

      @@ -14959,8 +14894,8 @@

      Static methods

      Execute all cleanup functions. Normally called for you after tearDown.

      - -
      + +
      def doCleanups(self):
           """Execute all cleanup functions. Normally called for you after
           tearDown."""
      @@ -14981,7 +14916,7 @@ 

      Static methods

      -
      +

      def fail(

      self, msg=None)

      @@ -14990,8 +14925,8 @@

      Static methods

      Fail immediately, with the given message.

      - -
      + +
      def fail(self, msg=None):
           """Fail immediately, with the given message."""
           raise self.failureException(msg)
      @@ -15004,7 +14939,7 @@ 

      Static methods

      -
      +

      def failIf(

      *args, **kwargs)

      @@ -15012,8 +14947,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -15028,7 +14963,7 @@ 

      Static methods

      -
      +

      def failIfAlmostEqual(

      *args, **kwargs)

      @@ -15036,8 +14971,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -15052,7 +14987,7 @@ 

      Static methods

      -
      +

      def failIfEqual(

      *args, **kwargs)

      @@ -15060,8 +14995,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -15076,7 +15011,7 @@ 

      Static methods

      -
      +

      def failUnless(

      *args, **kwargs)

      @@ -15084,8 +15019,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -15100,7 +15035,7 @@ 

      Static methods

      -
      +

      def failUnlessAlmostEqual(

      *args, **kwargs)

      @@ -15108,8 +15043,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -15124,7 +15059,7 @@ 

      Static methods

      -
      +

      def failUnlessEqual(

      *args, **kwargs)

      @@ -15132,8 +15067,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -15148,7 +15083,7 @@ 

      Static methods

      -
      +

      def failUnlessRaises(

      *args, **kwargs)

      @@ -15156,8 +15091,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -15172,7 +15107,7 @@ 

      Static methods

      -
      +

      def id(

      self)

      @@ -15180,8 +15115,8 @@

      Static methods

      - -
      + +
      def id(self):
           return "%s.%s" % (strclass(self.__class__), self._testMethodName)
       
      @@ -15193,7 +15128,7 @@

      Static methods

      -
      +

      def run(

      self, result=None)

      @@ -15201,8 +15136,8 @@

      Static methods

      - -
      + +
      def run(self, result=None):
           orig_result = result
           if result is None:
      @@ -15274,25 +15209,30 @@ 

      Static methods

      -
      +

      def setUp(

      self)

      -

      Hook method for setting up the test fixture before exercising it.

      - -
      + +
      def setUp(self):
      +    # Creating a log object
           data = {"Alice": {"email": 'alice@gmail.com',
                             "type": 'author',
      -                      "loc": 'Waterloo'},
      +                      "loc": 'Waterloo',
      +                      "books": ['BookA', 'BookB'],
      +                      "stars": [4, 5]},
                   "Bobby": {"email": 'bobby@gmail.com',
                             "type": 'author',
      -                      "loc": 'Kitchener'}}
      +                      "loc": 'Kitchener',
      +                      "books": ['BookC', 'BookD'],
      +                      "stars": [4, 4]}}
           self.log = gitnet.Log(data)
      +    self.df = self.log.df()
       
      @@ -15302,7 +15242,7 @@

      Static methods

      -
      +

      def shortDescription(

      self)

      @@ -15314,8 +15254,8 @@

      Static methods

      The default implementation of this method returns the first line of the specified test method's docstring.

      - -
      + +
      def shortDescription(self):
           """Returns a one-line description of the test, or None if no
           description has been provided.
      @@ -15333,7 +15273,7 @@ 

      Static methods

      -
      +

      def skipTest(

      self, reason)

      @@ -15342,8 +15282,8 @@

      Static methods

      Skip this test.

      - -
      + +
      def skipTest(self, reason):
           """Skip this test."""
           raise SkipTest(reason)
      @@ -15356,7 +15296,7 @@ 

      Static methods

      -
      +

      def subTest(

      *args, **kwds)

      @@ -15369,8 +15309,8 @@

      Static methods

      case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed.

      - -
      + +
      @contextlib.contextmanager
       def subTest(self, msg=None, **params):
           """Return a context manager that will return the enclosed block
      @@ -15410,7 +15350,7 @@ 

      Static methods

      -
      +

      def tearDown(

      self)

      @@ -15419,8 +15359,8 @@

      Static methods

      Hook method for deconstructing the test fixture after testing it.

      - -
      + +
      def tearDown(self):
           "Hook method for deconstructing the test fixture after testing it."
           pass
      @@ -15433,47 +15373,20 @@ 

      Static methods

      -
      +

      def test_basic(

      self)

      +

      Check that a dataframe is produced

      - -
      + +
      def test_basic(self):
      -    self.log.describe()
      -    self.assertIsNotNone(self.log.describe())
      -    self.assertIsInstance(self.log.describe(), str)
      -
      - -
      -
      - -
      - - -
      -
      -

      def test_filter_print(

      self)

      -
      - - - - -
      - -
      -
      def test_filter_print(self):
      -    self.log.filters = ["{} {} {} | Negate: {} | Helper: {}".format('age', '>', 10, False, None)]
      -    with patch('sys.stdout', new=StringIO()) as fake_out:
      -        self.log.describe()
      -        self.assertRegex(fake_out.getvalue(),
      -                         "Log containing 2 records from None created at ....-..-.. ..:..:..\.......\.\n"
      -                         "None\n"
      -                         "Filters:\tage > 10 | Negate: False | Helper: None")
      +    """Check that a dataframe is produced"""
      +    self.assertIsInstance(self.df, pd.DataFrame)
       
      @@ -15483,21 +15396,24 @@

      Static methods

      -
      -

      def test_print(

      self)

      +
      +

      def test_values(

      self)

      - -
      -
      def test_print(self):
      -    with patch('sys.stdout', new=StringIO()) as fake_out:
      -        self.log.describe()
      -        self.assertIn("Log containing 2 records from None created at", fake_out.getvalue())
      -        self.assertNotIn("Filter:", fake_out.getvalue())
      +  
      +  
      +
      def test_values(self):
      +    columns = ['books', 'email', 'loc', 'stars', 'type']
      +    index = ['Alice', 'Bobby']
      +    data = [[['BookA', 'BookB'], 'alice@gmail.com', 'Waterloo', [4, 5], 'author'],
      +            [['BookC', 'BookD'], 'bobby@gmail.com', 'Kitchener', [4, 4], 'author']]
      +    expected_df = pd.DataFrame(columns=columns, index=index, data=data)
      +    # Checking the created dataframe matches the expected dataframe
      +    assert_frame_equal(expected_df, self.df)
       
      @@ -15508,7 +15424,7 @@

      Static methods

      Methods

      -
      +

      def setUpClass(

      cls)

      @@ -15517,8 +15433,8 @@

      Methods

      Hook method for setting up class fixture before running tests in the class.

      - -
      + +
      @classmethod
       def setUpClass(cls):
           "Hook method for setting up class fixture before running tests in the class."
      @@ -15531,7 +15447,7 @@ 

      Methods

      -
      +

      def tearDownClass(

      cls)

      @@ -15540,8 +15456,8 @@

      Methods

      Hook method for deconstructing the class fixture after running all tests in the class.

      - -
      + +
      @classmethod
       def tearDownClass(cls):
           "Hook method for deconstructing the class fixture after running all tests in the class."
      @@ -15556,118 +15472,42 @@ 

      Methods

      -

      class DetectDuplicateEmailTests

      +

      class DescribeTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      - -
      -
      class DetectDuplicateEmailTests(unittest.TestCase):
      +  
      +  
      +
      class DescribeTests(unittest.TestCase):
           def setUp(self):
      -        data = {"Bob": {"author": 'Bob',
      -                        "email": 'bob@gmail.com',
      -                        "type": 'author'},
      -                "Bobby": {"author": 'Bobby',
      -                          "email": 'bob@gmail.com',
      -                          "type": 'author'},
      -                "Robert": {"author": 'Robert',
      -                           "email": 'bob@gmail.com',
      -                           "type": 'author'}}
      -
      +        data = {"Alice": {"email": 'alice@gmail.com',
      +                          "type": 'author',
      +                          "loc": 'Waterloo'},
      +                "Bobby": {"email": 'bobby@gmail.com',
      +                          "type": 'author',
      +                          "loc": 'Kitchener'}}
               self.log = gitnet.Log(data)
       
           def test_basic(self):
      -        """Is a dictionary returned and something printed?"""
      -        with patch('sys.stdout', new=StringIO()) as fake_out:
      -            res = self.log.detect_dup_emails()
      -            self.assertIsInstance(res, dict)
      -            self.assertIsInstance(fake_out.getvalue(),str)
      -            self.assertNotEqual(fake_out.getvalue(), "")
      -
      -    def test_dict(self):
      -        """Is a correct dictionary returned?"""
      -        dup_dict = self.log.detect_dup_emails()
      -
      -        self.assertIn('bob@gmail.com', dup_dict)
      -        self.assertEqual(len(dup_dict), 1)
      -
      -        self.assertEqual(len(dup_dict['bob@gmail.com']), 3)
      -        self.assertIn('Bob', dup_dict['bob@gmail.com'])
      -        self.assertIn('Bobby', dup_dict['bob@gmail.com'])
      -        self.assertIn('Robert', dup_dict['bob@gmail.com'])
      +        self.log.describe()
      +        self.assertIsNotNone(self.log.describe())
      +        self.assertIsInstance(self.log.describe(), str)
       
           def test_print(self):
      -        """Are correct messages being printed?"""
               with patch('sys.stdout', new=StringIO()) as fake_out:
      -            for i in range(1000):
      -                self.log.detect_dup_emails()
      -                output = fake_out.getvalue()
      -                self.assertIn("Emails associated with multiple authors:\n", output)
      -                self.assertTrue("bob@gmail.com: ['Bob', 'Bobby', 'Robert']" in output or
      -                                "bob@gmail.com: ['Bob', 'Robert', 'Bobby']" in output or
      -                                "bob@gmail.com: ['Bobby', 'Bob', 'Robert']" in output or
      -                                "bob@gmail.com: ['Bobby', 'Robert', 'Bob']" in output or
      -                                "bob@gmail.com: ['Robert', 'Bob', 'Bobby']" in output or
      -                                "bob@gmail.com: ['Robert', 'Bobby', 'Bob']" in output)
      -
      -                self.assertRegex(output, "Emails associated with multiple authors:"
      -                                         "\nbob@gmail.com: \[........................\]")
      -
      -    def test_no_warnings(self):
      -        """Are warnings not printed at the right times?"""
      -        with warnings.catch_warnings(record=True) as w:
      -            # Ensure warnings are being shown
      -            warnings.simplefilter("always")
      -            # Trigger Warning
      -            self.log.detect_dup_emails()
      -            # Check no warning occurred
      -            self.assertEqual(len(w), 0)
      -
      -    def test_warnings(self):
      -        """Are warnings printed at the right time?"""
      -        # Setting up a more complicated repository
      -        sub.call(["rm", "-rf", ".git"])
      -        sub.call(["cp", "-R", "repo_nx.git", ".git"])
      -        path = os.getcwd()
      -        nx_log = gitnet.get_log(path)
      +            self.log.describe()
      +            self.assertIn("Log containing 2 records from None created at", fake_out.getvalue())
      +            self.assertNotIn("Filter:", fake_out.getvalue())
       
      -        # Note: Depending on the environment a warning may or may not be raised. For example, PyCharm uses UTF-8
      -        #       encoding and thus will not raised the unicode error.
      -        with warnings.catch_warnings(record=True) as w:
      -            # Ensure warnings are being shown
      -            warnings.simplefilter("always")
      -            # Trigger Warning
      -            nx_log.detect_dup_emails()
      -            # Check warning occurs
      -            self.assertTrue(len(w) == 0 or len(w) == 1)
      +    def test_filter_print(self):
      +        self.log.filters = ["{} {} {} | Negate: {} | Helper: {}".format('age', '>', 10, False, None)]
       
      -    def tearDown(self):
      -        sub.call(["rm", "-rf", ".git"])
      +        with patch('sys.stdout', new=StringIO()) as fake_out:
      +            self.log.describe()
      +            self.assertRegex(fake_out.getvalue(),
      +                             "Log containing 2 records from None created at ....-..-.. ..:..:..\.......\.\n"
      +                             "None\n"
      +                             "Filters:\tage > 10 | Negate: False | Helper: None")
       
      @@ -15677,13 +15517,13 @@

      Methods

      Ancestors (in MRO)

      Class variables

      -

      var failureException

      +

      var failureException

      @@ -15693,7 +15533,7 @@

      Class variables

      -

      var longMessage

      +

      var longMessage

      @@ -15703,7 +15543,7 @@

      Class variables

      -

      var maxDiff

      +

      var maxDiff

      @@ -15715,7 +15555,7 @@

      Class variables

      Static methods

      -
      +

      def __init__(

      self, methodName='runTest')

      @@ -15726,8 +15566,8 @@

      Static methods

      method when executed. Raises a ValueError if the instance does not have a method with the specified name.

      - -
      + +
      def __init__(self, methodName='runTest'):
           """Create an instance of the class that will use the named test
              method when executed. Raises a ValueError if the instance does
      @@ -15767,7 +15607,7 @@ 

      Static methods

      -
      +

      def addCleanup(

      self, function, *args, **kwargs)

      @@ -15779,8 +15619,8 @@

      Static methods

      called after tearDown on test failure or success.

      Cleanup items are called even if setUp fails (unlike tearDown).

      - -
      + +
      def addCleanup(self, function, *args, **kwargs):
           """Add a function, with arguments, to be called when the test is
           completed. Functions added are called on a LIFO basis and are
      @@ -15796,7 +15636,7 @@ 

      Static methods

      -
      +

      def addTypeEqualityFunc(

      self, typeobj, function)

      @@ -15813,8 +15653,8 @@

      Static methods

      msg= argument that raises self.failureException with a useful error message when the two arguments are not equal.

      - -
      + +
      def addTypeEqualityFunc(self, typeobj, function):
           """Add a type specific assertEqual style function to compare a type.
           This method is for use by TestCase subclasses that need to register
      @@ -15836,7 +15676,7 @@ 

      Static methods

      -
      +

      def assertAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -15852,8 +15692,8 @@

      Static methods

      If the two objects compare equal then they will automatically compare almost equal.

      - -
      + +
      def assertAlmostEqual(self, first, second, places=None, msg=None,
                             delta=None):
           """Fail if the two objects are unequal as determined by their
      @@ -15895,7 +15735,7 @@ 

      Static methods

      -
      +

      def assertAlmostEquals(

      *args, **kwargs)

      @@ -15903,8 +15743,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -15919,7 +15759,7 @@ 

      Static methods

      -
      +

      def assertCountEqual(

      self, first, second, msg=None)

      @@ -15938,8 +15778,8 @@

      Static methods

      - [0, 1, 1] and [1, 0, 1] compare equal. - [0, 0, 1] and [0, 1] compare unequal.

      - -
      + +
      def assertCountEqual(self, first, second, msg=None):
           """An unordered sequence comparison asserting that the same elements,
           regardless of order.  If the same element occurs more than once,
      @@ -15977,7 +15817,7 @@ 

      Static methods

      -
      +

      def assertDictContainsSubset(

      self, subset, dictionary, msg=None)

      @@ -15986,8 +15826,8 @@

      Static methods

      Checks whether dictionary is a superset of subset.

      - -
      + +
      def assertDictContainsSubset(self, subset, dictionary, msg=None):
           """Checks whether dictionary is a superset of subset."""
           warnings.warn('assertDictContainsSubset is deprecated',
      @@ -16021,7 +15861,7 @@ 

      Static methods

      -
      +

      def assertDictEqual(

      self, d1, d2, msg=None)

      @@ -16029,8 +15869,8 @@

      Static methods

      - -
      + +
      def assertDictEqual(self, d1, d2, msg=None):
           self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
           self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
      @@ -16050,7 +15890,7 @@ 

      Static methods

      -
      +

      def assertEqual(

      self, first, second, msg=None)

      @@ -16060,8 +15900,8 @@

      Static methods

      Fail if the two objects are unequal as determined by the '==' operator.

      - -
      + +
      def assertEqual(self, first, second, msg=None):
           """Fail if the two objects are unequal as determined by the '=='
              operator.
      @@ -16077,7 +15917,7 @@ 

      Static methods

      -
      +

      def assertEquals(

      *args, **kwargs)

      @@ -16085,8 +15925,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -16101,7 +15941,7 @@ 

      Static methods

      -
      +

      def assertFalse(

      self, expr, msg=None)

      @@ -16110,8 +15950,8 @@

      Static methods

      Check that the expression is false.

      - -
      + +
      def assertFalse(self, expr, msg=None):
           """Check that the expression is false."""
           if expr:
      @@ -16126,7 +15966,7 @@ 

      Static methods

      -
      +

      def assertGreater(

      self, a, b, msg=None)

      @@ -16135,8 +15975,8 @@

      Static methods

      Just like self.assertTrue(a > b), but with a nicer default message.

      - -
      + +
      def assertGreater(self, a, b, msg=None):
           """Just like self.assertTrue(a > b), but with a nicer default message."""
           if not a > b:
      @@ -16151,7 +15991,7 @@ 

      Static methods

      -
      +

      def assertGreaterEqual(

      self, a, b, msg=None)

      @@ -16160,8 +16000,8 @@

      Static methods

      Just like self.assertTrue(a >= b), but with a nicer default message.

      - -
      + +
      def assertGreaterEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a >= b), but with a nicer default message."""
           if not a >= b:
      @@ -16176,7 +16016,7 @@ 

      Static methods

      -
      +

      def assertIn(

      self, member, container, msg=None)

      @@ -16185,8 +16025,8 @@

      Static methods

      Just like self.assertTrue(a in b), but with a nicer default message.

      - -
      + +
      def assertIn(self, member, container, msg=None):
           """Just like self.assertTrue(a in b), but with a nicer default message."""
           if member not in container:
      @@ -16202,7 +16042,7 @@ 

      Static methods

      -
      +

      def assertIs(

      self, expr1, expr2, msg=None)

      @@ -16211,8 +16051,8 @@

      Static methods

      Just like self.assertTrue(a is b), but with a nicer default message.

      - -
      + +
      def assertIs(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is b), but with a nicer default message."""
           if expr1 is not expr2:
      @@ -16228,7 +16068,7 @@ 

      Static methods

      -
      +

      def assertIsInstance(

      self, obj, cls, msg=None)

      @@ -16238,8 +16078,8 @@

      Static methods

      Same as self.assertTrue(isinstance(obj, cls)), with a nicer default message.

      - -
      + +
      def assertIsInstance(self, obj, cls, msg=None):
           """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
           default message."""
      @@ -16255,7 +16095,7 @@ 

      Static methods

      -
      +

      def assertIsNone(

      self, obj, msg=None)

      @@ -16264,8 +16104,8 @@

      Static methods

      Same as self.assertTrue(obj is None), with a nicer default message.

      - -
      + +
      def assertIsNone(self, obj, msg=None):
           """Same as self.assertTrue(obj is None), with a nicer default message."""
           if obj is not None:
      @@ -16280,7 +16120,7 @@ 

      Static methods

      -
      +

      def assertIsNot(

      self, expr1, expr2, msg=None)

      @@ -16289,8 +16129,8 @@

      Static methods

      Just like self.assertTrue(a is not b), but with a nicer default message.

      - -
      + +
      def assertIsNot(self, expr1, expr2, msg=None):
           """Just like self.assertTrue(a is not b), but with a nicer default message."""
           if expr1 is expr2:
      @@ -16305,7 +16145,7 @@ 

      Static methods

      -
      +

      def assertIsNotNone(

      self, obj, msg=None)

      @@ -16314,8 +16154,8 @@

      Static methods

      Included for symmetry with assertIsNone.

      - -
      + +
      def assertIsNotNone(self, obj, msg=None):
           """Included for symmetry with assertIsNone."""
           if obj is None:
      @@ -16330,7 +16170,7 @@ 

      Static methods

      -
      +

      def assertLess(

      self, a, b, msg=None)

      @@ -16339,8 +16179,8 @@

      Static methods

      Just like self.assertTrue(a < b), but with a nicer default message.

      - -
      + +
      def assertLess(self, a, b, msg=None):
           """Just like self.assertTrue(a < b), but with a nicer default message."""
           if not a < b:
      @@ -16355,7 +16195,7 @@ 

      Static methods

      -
      +

      def assertLessEqual(

      self, a, b, msg=None)

      @@ -16364,8 +16204,8 @@

      Static methods

      Just like self.assertTrue(a <= b), but with a nicer default message.

      - -
      + +
      def assertLessEqual(self, a, b, msg=None):
           """Just like self.assertTrue(a <= b), but with a nicer default message."""
           if not a <= b:
      @@ -16380,7 +16220,7 @@ 

      Static methods

      -
      +

      def assertListEqual(

      self, list1, list2, msg=None)

      @@ -16394,8 +16234,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertListEqual(self, list1, list2, msg=None):
           """A list-specific equality assertion.
           Args:
      @@ -16414,7 +16254,7 @@ 

      Static methods

      -
      +

      def assertLogs(

      self, logger=None, level=None)

      @@ -16438,8 +16278,8 @@

      Static methods

      'ERROR:foo.bar:second message'])
      - -
      + +
      def assertLogs(self, logger=None, level=None):
           """Fail unless a log message of level *level* or higher is emitted
           on *logger_name* or its children.  If omitted, *level* defaults to
      @@ -16467,7 +16307,7 @@ 

      Static methods

      -
      +

      def assertMultiLineEqual(

      self, first, second, msg=None)

      @@ -16476,8 +16316,8 @@

      Static methods

      Assert that two multi-line strings are equal.

      - -
      + +
      def assertMultiLineEqual(self, first, second, msg=None):
           """Assert that two multi-line strings are equal."""
           self.assertIsInstance(first, str, 'First argument is not a string')
      @@ -16505,7 +16345,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      @@ -16520,8 +16360,8 @@

      Static methods

      as significant digits (measured from the most signficant digit).

      Objects that are equal automatically fail.

      - -
      + +
      def assertNotAlmostEqual(self, first, second, places=None, msg=None,
                                delta=None):
           """Fail if the two objects are equal as determined by their
      @@ -16559,7 +16399,7 @@ 

      Static methods

      -
      +

      def assertNotAlmostEquals(

      *args, **kwargs)

      @@ -16567,8 +16407,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -16583,7 +16423,7 @@ 

      Static methods

      -
      +

      def assertNotEqual(

      self, first, second, msg=None)

      @@ -16593,8 +16433,8 @@

      Static methods

      Fail if the two objects are equal as determined by the '!=' operator.

      - -
      + +
      def assertNotEqual(self, first, second, msg=None):
           """Fail if the two objects are equal as determined by the '!='
              operator.
      @@ -16612,7 +16452,7 @@ 

      Static methods

      -
      +

      def assertNotEquals(

      *args, **kwargs)

      @@ -16620,8 +16460,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -16636,7 +16476,7 @@ 

      Static methods

      -
      +

      def assertNotIn(

      self, member, container, msg=None)

      @@ -16645,8 +16485,8 @@

      Static methods

      Just like self.assertTrue(a not in b), but with a nicer default message.

      - -
      + +
      def assertNotIn(self, member, container, msg=None):
           """Just like self.assertTrue(a not in b), but with a nicer default message."""
           if member in container:
      @@ -16662,7 +16502,7 @@ 

      Static methods

      -
      +

      def assertNotIsInstance(

      self, obj, cls, msg=None)

      @@ -16671,8 +16511,8 @@

      Static methods

      Included for symmetry with assertIsInstance.

      - -
      + +
      def assertNotIsInstance(self, obj, cls, msg=None):
           """Included for symmetry with assertIsInstance."""
           if isinstance(obj, cls):
      @@ -16687,7 +16527,7 @@ 

      Static methods

      -
      +

      def assertNotRegex(

      self, text, unexpected_regex, msg=None)

      @@ -16696,20 +16536,19 @@

      Static methods

      Fail the test if the text matches the regular expression.

      - -
      + +
      def assertNotRegex(self, text, unexpected_regex, msg=None):
           """Fail the test if the text matches the regular expression."""
           if isinstance(unexpected_regex, (str, bytes)):
               unexpected_regex = re.compile(unexpected_regex)
           match = unexpected_regex.search(text)
           if match:
      -        standardMsg = 'Regex matched: %r matches %r in %r' % (
      -            text[match.start() : match.end()],
      -            unexpected_regex.pattern,
      -            text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex matched"
      +        msg = '%s: %r matches %r in %r' % (msg,
      +                                           text[match.start():match.end()],
      +                                           unexpected_regex.pattern,
      +                                           text)
               raise self.failureException(msg)
       
      @@ -16720,44 +16559,20 @@

      Static methods

      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - - -
      -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +
      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -16775,16 +16590,16 @@ 

      Static methods

      self.assertEqual(the_exception.error_code, 3)
      - -
      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +  
      +  
      +
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -16798,8 +16613,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -16809,8 +16624,8 @@

      Static methods

      -
      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +
      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -16821,27 +16636,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -16851,7 +16669,7 @@

      Static methods

      -
      +

      def assertRaisesRegexp(

      *args, **kwargs)

      @@ -16859,8 +16677,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -16875,7 +16693,7 @@ 

      Static methods

      -
      +

      def assertRegex(

      self, text, expected_regex, msg=None)

      @@ -16884,18 +16702,16 @@

      Static methods

      Fail the test unless the text matches the regular expression.

      - -
      + +
      def assertRegex(self, text, expected_regex, msg=None):
           """Fail the test unless the text matches the regular expression."""
           if isinstance(expected_regex, (str, bytes)):
               assert expected_regex, "expected_regex must not be empty."
               expected_regex = re.compile(expected_regex)
           if not expected_regex.search(text):
      -        standardMsg = "Regex didn't match: %r not found in %r" % (
      -            expected_regex.pattern, text)
      -        # _formatMessage ensures the longMessage option is respected
      -        msg = self._formatMessage(msg, standardMsg)
      +        msg = msg or "Regex didn't match"
      +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
               raise self.failureException(msg)
       
      @@ -16906,7 +16722,7 @@

      Static methods

      -
      +

      def assertRegexpMatches(

      *args, **kwargs)

      @@ -16914,8 +16730,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -16930,7 +16746,7 @@ 

      Static methods

      -
      +

      def assertSequenceEqual(

      self, seq1, seq2, msg=None, seq_type=None)

      @@ -16948,8 +16764,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
           """An equality assertion for ordered sequences (like lists and tuples).
           For the purposes of this function, a valid ordered sequence type is one
      @@ -17046,7 +16862,7 @@ 

      Static methods

      -
      +

      def assertSetEqual(

      self, set1, set2, msg=None)

      @@ -17063,8 +16879,8 @@

      Static methods

      is optimized for sets specifically (parameters must support a difference method).

      - -
      + +
      def assertSetEqual(self, set1, set2, msg=None):
           """A set-specific equality assertion.
           Args:
      @@ -17110,7 +16926,7 @@ 

      Static methods

      -
      +

      def assertTrue(

      self, expr, msg=None)

      @@ -17119,8 +16935,8 @@

      Static methods

      Check that the expression is true.

      - -
      + +
      def assertTrue(self, expr, msg=None):
           """Check that the expression is true."""
           if not expr:
      @@ -17135,7 +16951,7 @@ 

      Static methods

      -
      +

      def assertTupleEqual(

      self, tuple1, tuple2, msg=None)

      @@ -17149,8 +16965,8 @@

      Static methods

      msg: Optional message to use on failure instead of a list of differences.

      - -
      + +
      def assertTupleEqual(self, tuple1, tuple2, msg=None):
           """A tuple-specific equality assertion.
           Args:
      @@ -17169,20 +16985,20 @@ 

      Static methods

      -
      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +
      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -17202,16 +17018,16 @@ 

      Static methods

      self.assertEqual(the_warning.some_attribute, 147)
      - -
      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +  
      +  
      +
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -17227,8 +17043,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -17238,8 +17054,8 @@

      Static methods

      -
      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +
      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -17253,15 +17069,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      - -
      + +
      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -17270,13 +17087,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -17286,7 +17105,7 @@

      Static methods

      -
      +

      def assert_(

      *args, **kwargs)

      @@ -17294,8 +17113,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -17310,7 +17129,7 @@ 

      Static methods

      -
      +

      def countTestCases(

      self)

      @@ -17318,8 +17137,8 @@

      Static methods

      - -
      + +
      def countTestCases(self):
           return 1
       
      @@ -17331,7 +17150,7 @@

      Static methods

      -
      +

      def debug(

      self)

      @@ -17340,8 +17159,8 @@

      Static methods

      Run the test without collecting errors in a TestResult

      - -
      + +
      def debug(self):
           """Run the test without collecting errors in a TestResult"""
           self.setUp()
      @@ -17359,7 +17178,7 @@ 

      Static methods

      -
      +

      def defaultTestResult(

      self)

      @@ -17367,8 +17186,8 @@

      Static methods

      - -
      + +
      def defaultTestResult(self):
           return result.TestResult()
       
      @@ -17380,7 +17199,7 @@

      Static methods

      -
      +

      def doCleanups(

      self)

      @@ -17390,8 +17209,8 @@

      Static methods

      Execute all cleanup functions. Normally called for you after tearDown.

      - -
      + +
      def doCleanups(self):
           """Execute all cleanup functions. Normally called for you after
           tearDown."""
      @@ -17412,7 +17231,7 @@ 

      Static methods

      -
      +

      def fail(

      self, msg=None)

      @@ -17421,8 +17240,8 @@

      Static methods

      Fail immediately, with the given message.

      - -
      + +
      def fail(self, msg=None):
           """Fail immediately, with the given message."""
           raise self.failureException(msg)
      @@ -17435,7 +17254,7 @@ 

      Static methods

      -
      +

      def failIf(

      *args, **kwargs)

      @@ -17443,8 +17262,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -17459,7 +17278,7 @@ 

      Static methods

      -
      +

      def failIfAlmostEqual(

      *args, **kwargs)

      @@ -17467,8 +17286,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -17483,7 +17302,7 @@ 

      Static methods

      -
      +

      def failIfEqual(

      *args, **kwargs)

      @@ -17491,8 +17310,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -17507,7 +17326,7 @@ 

      Static methods

      -
      +

      def failUnless(

      *args, **kwargs)

      @@ -17515,8 +17334,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -17531,7 +17350,7 @@ 

      Static methods

      -
      +

      def failUnlessAlmostEqual(

      *args, **kwargs)

      @@ -17539,8 +17358,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -17555,7 +17374,7 @@ 

      Static methods

      -
      +

      def failUnlessEqual(

      *args, **kwargs)

      @@ -17563,8 +17382,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -17579,7 +17398,7 @@ 

      Static methods

      -
      +

      def failUnlessRaises(

      *args, **kwargs)

      @@ -17587,8 +17406,8 @@

      Static methods

      - -
      + +
      def deprecated_func(*args, **kwargs):
           warnings.warn(
               'Please use {0} instead.'.format(original_func.__name__),
      @@ -17603,7 +17422,7 @@ 

      Static methods

      -
      +

      def id(

      self)

      @@ -17611,8 +17430,8 @@

      Static methods

      - -
      + +
      def id(self):
           return "%s.%s" % (strclass(self.__class__), self._testMethodName)
       
      @@ -17624,7 +17443,7 @@

      Static methods

      -
      +

      def run(

      self, result=None)

      @@ -17632,8 +17451,8 @@

      Static methods

      - -
      + +
      def run(self, result=None):
           orig_result = result
           if result is None:
      @@ -17705,27 +17524,23 @@ 

      Static methods

      -
      +

      def setUp(

      self)

      -

      Hook method for setting up the test fixture before exercising it.

      - -
      + +
      def setUp(self):
      -    data = {"Bob": {"author": 'Bob',
      -                    "email": 'bob@gmail.com',
      -                    "type": 'author'},
      -            "Bobby": {"author": 'Bobby',
      -                      "email": 'bob@gmail.com',
      -                      "type": 'author'},
      -            "Robert": {"author": 'Robert',
      -                       "email": 'bob@gmail.com',
      -                       "type": 'author'}}
      +    data = {"Alice": {"email": 'alice@gmail.com',
      +                      "type": 'author',
      +                      "loc": 'Waterloo'},
      +            "Bobby": {"email": 'bobby@gmail.com',
      +                      "type": 'author',
      +                      "loc": 'Kitchener'}}
           self.log = gitnet.Log(data)
       
      @@ -17736,7 +17551,7 @@

      Static methods

      -
      +

      def shortDescription(

      self)

      @@ -17748,8 +17563,8 @@

      Static methods

      The default implementation of this method returns the first line of the specified test method's docstring.

      - -
      + +
      def shortDescription(self):
           """Returns a one-line description of the test, or None if no
           description has been provided.
      @@ -17767,7 +17582,7 @@ 

      Static methods

      -
      +

      def skipTest(

      self, reason)

      @@ -17776,8 +17591,8 @@

      Static methods

      Skip this test.

      - -
      + +
      def skipTest(self, reason):
           """Skip this test."""
           raise SkipTest(reason)
      @@ -17790,7 +17605,7 @@ 

      Static methods

      -
      +

      def subTest(

      *args, **kwds)

      @@ -17803,8 +17618,2395 @@

      Static methods

      case as failed but resumes execution at the end of the enclosed block, allowing further test code to be executed.

      - -
      + +
      +
      @contextlib.contextmanager
      +def subTest(self, msg=None, **params):
      +    """Return a context manager that will return the enclosed block
      +    of code in a subtest identified by the optional message and
      +    keyword parameters.  A failure in the subtest marks the test
      +    case as failed but resumes execution at the end of the enclosed
      +    block, allowing further test code to be executed.
      +    """
      +    if not self._outcome.result_supports_subtests:
      +        yield
      +        return
      +    parent = self._subtest
      +    if parent is None:
      +        params_map = collections.ChainMap(params)
      +    else:
      +        params_map = parent.params.new_child(params)
      +    self._subtest = _SubTest(self, msg, params_map)
      +    try:
      +        with self._outcome.testPartExecutor(self._subtest, isTest=True):
      +            yield
      +        if not self._outcome.success:
      +            result = self._outcome.result
      +            if result is not None and result.failfast:
      +                raise _ShouldStop
      +        elif self._outcome.expectedFailure:
      +            # If the test is expecting a failure, we really want to
      +            # stop now and register the expected failure.
      +            raise _ShouldStop
      +    finally:
      +        self._subtest = parent
      +
      + +
      +
      + +
      + + +
      +
      +

      def tearDown(

      self)

      +
      + + + + +

      Hook method for deconstructing the test fixture after testing it.

      +
      + +
      +
      def tearDown(self):
      +    "Hook method for deconstructing the test fixture after testing it."
      +    pass
      +
      + +
      +
      + +
      + + +
      +
      +

      def test_basic(

      self)

      +
      + + + + +
      + +
      +
      def test_basic(self):
      +    self.log.describe()
      +    self.assertIsNotNone(self.log.describe())
      +    self.assertIsInstance(self.log.describe(), str)
      +
      + +
      +
      + +
      + + +
      +
      +

      def test_filter_print(

      self)

      +
      + + + + +
      + +
      +
      def test_filter_print(self):
      +    self.log.filters = ["{} {} {} | Negate: {} | Helper: {}".format('age', '>', 10, False, None)]
      +    with patch('sys.stdout', new=StringIO()) as fake_out:
      +        self.log.describe()
      +        self.assertRegex(fake_out.getvalue(),
      +                         "Log containing 2 records from None created at ....-..-.. ..:..:..\.......\.\n"
      +                         "None\n"
      +                         "Filters:\tage > 10 | Negate: False | Helper: None")
      +
      + +
      +
      + +
      + + +
      +
      +

      def test_print(

      self)

      +
      + + + + +
      + +
      +
      def test_print(self):
      +    with patch('sys.stdout', new=StringIO()) as fake_out:
      +        self.log.describe()
      +        self.assertIn("Log containing 2 records from None created at", fake_out.getvalue())
      +        self.assertNotIn("Filter:", fake_out.getvalue())
      +
      + +
      +
      + +
      + +

      Methods

      + +
      +
      +

      def setUpClass(

      cls)

      +
      + + + + +

      Hook method for setting up class fixture before running tests in the class.

      +
      + +
      +
      @classmethod
      +def setUpClass(cls):
      +    "Hook method for setting up class fixture before running tests in the class."
      +
      + +
      +
      + +
      + + +
      +
      +

      def tearDownClass(

      cls)

      +
      + + + + +

      Hook method for deconstructing the class fixture after running all tests in the class.

      +
      + +
      +
      @classmethod
      +def tearDownClass(cls):
      +    "Hook method for deconstructing the class fixture after running all tests in the class."
      +
      + +
      +
      + +
      + +
      +
      + +
      +

      class DetectDuplicateEmailTests

      + + +
      + +
      +
      class DetectDuplicateEmailTests(unittest.TestCase):
      +    def setUp(self):
      +        data = {"Bob": {"author": 'Bob',
      +                        "email": 'bob@gmail.com',
      +                        "type": 'author'},
      +                "Bobby": {"author": 'Bobby',
      +                          "email": 'bob@gmail.com',
      +                          "type": 'author'},
      +                "Robert": {"author": 'Robert',
      +                           "email": 'bob@gmail.com',
      +                           "type": 'author'}}
      +
      +        self.log = gitnet.Log(data)
      +
      +    def test_basic(self):
      +        """Is a dictionary returned and something printed?"""
      +        with patch('sys.stdout', new=StringIO()) as fake_out:
      +            res = self.log.detect_dup_emails()
      +            self.assertIsInstance(res, dict)
      +            self.assertIsInstance(fake_out.getvalue(),str)
      +            self.assertNotEqual(fake_out.getvalue(), "")
      +
      +    def test_dict(self):
      +        """Is a correct dictionary returned?"""
      +        dup_dict = self.log.detect_dup_emails()
      +
      +        self.assertIn('bob@gmail.com', dup_dict)
      +        self.assertEqual(len(dup_dict), 1)
      +
      +        self.assertEqual(len(dup_dict['bob@gmail.com']), 3)
      +        self.assertIn('Bob', dup_dict['bob@gmail.com'])
      +        self.assertIn('Bobby', dup_dict['bob@gmail.com'])
      +        self.assertIn('Robert', dup_dict['bob@gmail.com'])
      +
      +    def test_print(self):
      +        """Are correct messages being printed?"""
      +        with patch('sys.stdout', new=StringIO()) as fake_out:
      +            for i in range(1000):
      +                self.log.detect_dup_emails()
      +                output = fake_out.getvalue()
      +                self.assertIn("Emails associated with multiple authors:\n", output)
      +                self.assertTrue("bob@gmail.com: ['Bob', 'Bobby', 'Robert']" in output or
      +                                "bob@gmail.com: ['Bob', 'Robert', 'Bobby']" in output or
      +                                "bob@gmail.com: ['Bobby', 'Bob', 'Robert']" in output or
      +                                "bob@gmail.com: ['Bobby', 'Robert', 'Bob']" in output or
      +                                "bob@gmail.com: ['Robert', 'Bob', 'Bobby']" in output or
      +                                "bob@gmail.com: ['Robert', 'Bobby', 'Bob']" in output)
      +
      +                self.assertRegex(output, "Emails associated with multiple authors:"
      +                                         "\nbob@gmail.com: \[........................\]")
      +
      +    def test_no_warnings(self):
      +        """Are warnings not printed at the right times?"""
      +        with warnings.catch_warnings(record=True) as w:
      +            # Ensure warnings are being shown
      +            warnings.simplefilter("always")
      +            # Trigger Warning
      +            self.log.detect_dup_emails()
      +            # Check no warning occurred
      +            self.assertEqual(len(w), 0)
      +
      +    def test_warnings(self):
      +        """Are warnings printed at the right time?"""
      +        # Setting up a more complicated repository
      +        sub.call(["rm", "-rf", ".git"])
      +        sub.call(["cp", "-R", "repo_nx.git", ".git"])
      +        path = os.getcwd()
      +        nx_log = gitnet.get_log(path)
      +
      +        # Note: Depending on the environment a warning may or may not be raised. For example, PyCharm uses UTF-8
      +        #       encoding and thus will not raised the unicode error.
      +        with warnings.catch_warnings(record=True) as w:
      +            # Ensure warnings are being shown
      +            warnings.simplefilter("always")
      +            # Trigger Warning
      +            nx_log.detect_dup_emails()
      +            # Check warning occurs
      +            self.assertTrue(len(w) == 0 or len(w) == 1)
      +
      +    def tearDown(self):
      +        sub.call(["rm", "-rf", ".git"])
      +
      + +
      +
      + + +
      +

      Ancestors (in MRO)

      + +

      Class variables

      +
      +

      var failureException

      + + + + +
      +
      + +
      +
      +

      var longMessage

      + + + + +
      +
      + +
      +
      +

      var maxDiff

      + + + + +
      +
      + +
      +

      Static methods

      + +
      +
      +

      def __init__(

      self, methodName='runTest')

      +
      + + + + +

      Create an instance of the class that will use the named test +method when executed. Raises a ValueError if the instance does +not have a method with the specified name.

      +
      + +
      +
      def __init__(self, methodName='runTest'):
      +    """Create an instance of the class that will use the named test
      +       method when executed. Raises a ValueError if the instance does
      +       not have a method with the specified name.
      +    """
      +    self._testMethodName = methodName
      +    self._outcome = None
      +    self._testMethodDoc = 'No test'
      +    try:
      +        testMethod = getattr(self, methodName)
      +    except AttributeError:
      +        if methodName != 'runTest':
      +            # we allow instantiation with no explicit method name
      +            # but not an *incorrect* or missing method name
      +            raise ValueError("no such test method in %s: %s" %
      +                  (self.__class__, methodName))
      +    else:
      +        self._testMethodDoc = testMethod.__doc__
      +    self._cleanups = []
      +    self._subtest = None
      +    # Map types to custom assertEqual functions that will compare
      +    # instances of said type in more detail to generate a more useful
      +    # error message.
      +    self._type_equality_funcs = {}
      +    self.addTypeEqualityFunc(dict, 'assertDictEqual')
      +    self.addTypeEqualityFunc(list, 'assertListEqual')
      +    self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
      +    self.addTypeEqualityFunc(set, 'assertSetEqual')
      +    self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
      +    self.addTypeEqualityFunc(str, 'assertMultiLineEqual')
      +
      + +
      +
      + +
      + + +
      +
      +

      def addCleanup(

      self, function, *args, **kwargs)

      +
      + + + + +

      Add a function, with arguments, to be called when the test is +completed. Functions added are called on a LIFO basis and are +called after tearDown on test failure or success.

      +

      Cleanup items are called even if setUp fails (unlike tearDown).

      +
      + +
      +
      def addCleanup(self, function, *args, **kwargs):
      +    """Add a function, with arguments, to be called when the test is
      +    completed. Functions added are called on a LIFO basis and are
      +    called after tearDown on test failure or success.
      +    Cleanup items are called even if setUp fails (unlike tearDown)."""
      +    self._cleanups.append((function, args, kwargs))
      +
      + +
      +
      + +
      + + +
      +
      +

      def addTypeEqualityFunc(

      self, typeobj, function)

      +
      + + + + +

      Add a type specific assertEqual style function to compare a type.

      +

      This method is for use by TestCase subclasses that need to register +their own type equality functions to provide nicer error messages.

      +

      Args: + typeobj: The data type to call this function on when both values + are of the same type in assertEqual(). + function: The callable taking two arguments and an optional + msg= argument that raises self.failureException with a + useful error message when the two arguments are not equal.

      +
      + +
      +
      def addTypeEqualityFunc(self, typeobj, function):
      +    """Add a type specific assertEqual style function to compare a type.
      +    This method is for use by TestCase subclasses that need to register
      +    their own type equality functions to provide nicer error messages.
      +    Args:
      +        typeobj: The data type to call this function on when both values
      +                are of the same type in assertEqual().
      +        function: The callable taking two arguments and an optional
      +                msg= argument that raises self.failureException with a
      +                useful error message when the two arguments are not equal.
      +    """
      +    self._type_equality_funcs[typeobj] = function
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      +
      + + + + +

      Fail if the two objects are unequal as determined by their +difference rounded to the given number of decimal places +(default 7) and comparing to zero, or by comparing that the +between the two objects is more than the given delta.

      +

      Note that decimal places (from zero) are usually not the same +as significant digits (measured from the most signficant digit).

      +

      If the two objects compare equal then they will automatically +compare almost equal.

      +
      + +
      +
      def assertAlmostEqual(self, first, second, places=None, msg=None,
      +                      delta=None):
      +    """Fail if the two objects are unequal as determined by their
      +       difference rounded to the given number of decimal places
      +       (default 7) and comparing to zero, or by comparing that the
      +       between the two objects is more than the given delta.
      +       Note that decimal places (from zero) are usually not the same
      +       as significant digits (measured from the most signficant digit).
      +       If the two objects compare equal then they will automatically
      +       compare almost equal.
      +    """
      +    if first == second:
      +        # shortcut
      +        return
      +    if delta is not None and places is not None:
      +        raise TypeError("specify delta or places not both")
      +    if delta is not None:
      +        if abs(first - second) <= delta:
      +            return
      +        standardMsg = '%s != %s within %s delta' % (safe_repr(first),
      +                                                    safe_repr(second),
      +                                                    safe_repr(delta))
      +    else:
      +        if places is None:
      +            places = 7
      +        if round(abs(second-first), places) == 0:
      +            return
      +        standardMsg = '%s != %s within %r places' % (safe_repr(first),
      +                                                      safe_repr(second),
      +                                                      places)
      +    msg = self._formatMessage(msg, standardMsg)
      +    raise self.failureException(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertAlmostEquals(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertCountEqual(

      self, first, second, msg=None)

      +
      + + + + +

      An unordered sequence comparison asserting that the same elements, +regardless of order. If the same element occurs more than once, +it verifies that the elements occur the same number of times.

      +
      self.assertEqual(Counter(list(first)),
      +                 Counter(list(second)))
      +
      + + +

      Example: + - [0, 1, 1] and [1, 0, 1] compare equal. + - [0, 0, 1] and [0, 1] compare unequal.

      +
      + +
      +
      def assertCountEqual(self, first, second, msg=None):
      +    """An unordered sequence comparison asserting that the same elements,
      +    regardless of order.  If the same element occurs more than once,
      +    it verifies that the elements occur the same number of times.
      +        self.assertEqual(Counter(list(first)),
      +                         Counter(list(second)))
      +     Example:
      +        - [0, 1, 1] and [1, 0, 1] compare equal.
      +        - [0, 0, 1] and [0, 1] compare unequal.
      +    """
      +    first_seq, second_seq = list(first), list(second)
      +    try:
      +        first = collections.Counter(first_seq)
      +        second = collections.Counter(second_seq)
      +    except TypeError:
      +        # Handle case with unhashable elements
      +        differences = _count_diff_all_purpose(first_seq, second_seq)
      +    else:
      +        if first == second:
      +            return
      +        differences = _count_diff_hashable(first_seq, second_seq)
      +    if differences:
      +        standardMsg = 'Element counts were not equal:\n'
      +        lines = ['First has %d, Second has %d:  %r' % diff for diff in differences]
      +        diffMsg = '\n'.join(lines)
      +        standardMsg = self._truncateMessage(standardMsg, diffMsg)
      +        msg = self._formatMessage(msg, standardMsg)
      +        self.fail(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertDictContainsSubset(

      self, subset, dictionary, msg=None)

      +
      + + + + +

      Checks whether dictionary is a superset of subset.

      +
      + +
      +
      def assertDictContainsSubset(self, subset, dictionary, msg=None):
      +    """Checks whether dictionary is a superset of subset."""
      +    warnings.warn('assertDictContainsSubset is deprecated',
      +                  DeprecationWarning)
      +    missing = []
      +    mismatched = []
      +    for key, value in subset.items():
      +        if key not in dictionary:
      +            missing.append(key)
      +        elif value != dictionary[key]:
      +            mismatched.append('%s, expected: %s, actual: %s' %
      +                              (safe_repr(key), safe_repr(value),
      +                               safe_repr(dictionary[key])))
      +    if not (missing or mismatched):
      +        return
      +    standardMsg = ''
      +    if missing:
      +        standardMsg = 'Missing: %s' % ','.join(safe_repr(m) for m in
      +                                                missing)
      +    if mismatched:
      +        if standardMsg:
      +            standardMsg += '; '
      +        standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
      +    self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertDictEqual(

      self, d1, d2, msg=None)

      +
      + + + + +
      + +
      +
      def assertDictEqual(self, d1, d2, msg=None):
      +    self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
      +    self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
      +    if d1 != d2:
      +        standardMsg = '%s != %s' % _common_shorten_repr(d1, d2)
      +        diff = ('\n' + '\n'.join(difflib.ndiff(
      +                       pprint.pformat(d1).splitlines(),
      +                       pprint.pformat(d2).splitlines())))
      +        standardMsg = self._truncateMessage(standardMsg, diff)
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertEqual(

      self, first, second, msg=None)

      +
      + + + + +

      Fail if the two objects are unequal as determined by the '==' +operator.

      +
      + +
      +
      def assertEqual(self, first, second, msg=None):
      +    """Fail if the two objects are unequal as determined by the '=='
      +       operator.
      +    """
      +    assertion_func = self._getAssertEqualityFunc(first, second)
      +    assertion_func(first, second, msg=msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertEquals(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertFalse(

      self, expr, msg=None)

      +
      + + + + +

      Check that the expression is false.

      +
      + +
      +
      def assertFalse(self, expr, msg=None):
      +    """Check that the expression is false."""
      +    if expr:
      +        msg = self._formatMessage(msg, "%s is not false" % safe_repr(expr))
      +        raise self.failureException(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertGreater(

      self, a, b, msg=None)

      +
      + + + + +

      Just like self.assertTrue(a > b), but with a nicer default message.

      +
      + +
      +
      def assertGreater(self, a, b, msg=None):
      +    """Just like self.assertTrue(a > b), but with a nicer default message."""
      +    if not a > b:
      +        standardMsg = '%s not greater than %s' % (safe_repr(a), safe_repr(b))
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertGreaterEqual(

      self, a, b, msg=None)

      +
      + + + + +

      Just like self.assertTrue(a >= b), but with a nicer default message.

      +
      + +
      +
      def assertGreaterEqual(self, a, b, msg=None):
      +    """Just like self.assertTrue(a >= b), but with a nicer default message."""
      +    if not a >= b:
      +        standardMsg = '%s not greater than or equal to %s' % (safe_repr(a), safe_repr(b))
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertIn(

      self, member, container, msg=None)

      +
      + + + + +

      Just like self.assertTrue(a in b), but with a nicer default message.

      +
      + +
      +
      def assertIn(self, member, container, msg=None):
      +    """Just like self.assertTrue(a in b), but with a nicer default message."""
      +    if member not in container:
      +        standardMsg = '%s not found in %s' % (safe_repr(member),
      +                                              safe_repr(container))
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertIs(

      self, expr1, expr2, msg=None)

      +
      + + + + +

      Just like self.assertTrue(a is b), but with a nicer default message.

      +
      + +
      +
      def assertIs(self, expr1, expr2, msg=None):
      +    """Just like self.assertTrue(a is b), but with a nicer default message."""
      +    if expr1 is not expr2:
      +        standardMsg = '%s is not %s' % (safe_repr(expr1),
      +                                         safe_repr(expr2))
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertIsInstance(

      self, obj, cls, msg=None)

      +
      + + + + +

      Same as self.assertTrue(isinstance(obj, cls)), with a nicer +default message.

      +
      + +
      +
      def assertIsInstance(self, obj, cls, msg=None):
      +    """Same as self.assertTrue(isinstance(obj, cls)), with a nicer
      +    default message."""
      +    if not isinstance(obj, cls):
      +        standardMsg = '%s is not an instance of %r' % (safe_repr(obj), cls)
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertIsNone(

      self, obj, msg=None)

      +
      + + + + +

      Same as self.assertTrue(obj is None), with a nicer default message.

      +
      + +
      +
      def assertIsNone(self, obj, msg=None):
      +    """Same as self.assertTrue(obj is None), with a nicer default message."""
      +    if obj is not None:
      +        standardMsg = '%s is not None' % (safe_repr(obj),)
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertIsNot(

      self, expr1, expr2, msg=None)

      +
      + + + + +

      Just like self.assertTrue(a is not b), but with a nicer default message.

      +
      + +
      +
      def assertIsNot(self, expr1, expr2, msg=None):
      +    """Just like self.assertTrue(a is not b), but with a nicer default message."""
      +    if expr1 is expr2:
      +        standardMsg = 'unexpectedly identical: %s' % (safe_repr(expr1),)
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertIsNotNone(

      self, obj, msg=None)

      +
      + + + + +

      Included for symmetry with assertIsNone.

      +
      + +
      +
      def assertIsNotNone(self, obj, msg=None):
      +    """Included for symmetry with assertIsNone."""
      +    if obj is None:
      +        standardMsg = 'unexpectedly None'
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertLess(

      self, a, b, msg=None)

      +
      + + + + +

      Just like self.assertTrue(a < b), but with a nicer default message.

      +
      + +
      +
      def assertLess(self, a, b, msg=None):
      +    """Just like self.assertTrue(a < b), but with a nicer default message."""
      +    if not a < b:
      +        standardMsg = '%s not less than %s' % (safe_repr(a), safe_repr(b))
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertLessEqual(

      self, a, b, msg=None)

      +
      + + + + +

      Just like self.assertTrue(a <= b), but with a nicer default message.

      +
      + +
      +
      def assertLessEqual(self, a, b, msg=None):
      +    """Just like self.assertTrue(a <= b), but with a nicer default message."""
      +    if not a <= b:
      +        standardMsg = '%s not less than or equal to %s' % (safe_repr(a), safe_repr(b))
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertListEqual(

      self, list1, list2, msg=None)

      +
      + + + + +

      A list-specific equality assertion.

      +

      Args: + list1: The first list to compare. + list2: The second list to compare. + msg: Optional message to use on failure instead of a list of + differences.

      +
      + +
      +
      def assertListEqual(self, list1, list2, msg=None):
      +    """A list-specific equality assertion.
      +    Args:
      +        list1: The first list to compare.
      +        list2: The second list to compare.
      +        msg: Optional message to use on failure instead of a list of
      +                differences.
      +    """
      +    self.assertSequenceEqual(list1, list2, msg, seq_type=list)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertLogs(

      self, logger=None, level=None)

      +
      + + + + +

      Fail unless a log message of level level or higher is emitted +on logger_name or its children. If omitted, level defaults to +INFO and logger defaults to the root logger.

      +

      This method must be used as a context manager, and will yield +a recording object with two attributes: output and records. +At the end of the context manager, the output attribute will +be a list of the matching formatted log messages and the +records attribute will be a list of the corresponding LogRecord +objects.

      +

      Example::

      +
      with self.assertLogs('foo', level='INFO') as cm:
      +    logging.getLogger('foo').info('first message')
      +    logging.getLogger('foo.bar').error('second message')
      +self.assertEqual(cm.output, ['INFO:foo:first message',
      +                             'ERROR:foo.bar:second message'])
      +
      +
      + +
      +
      def assertLogs(self, logger=None, level=None):
      +    """Fail unless a log message of level *level* or higher is emitted
      +    on *logger_name* or its children.  If omitted, *level* defaults to
      +    INFO and *logger* defaults to the root logger.
      +    This method must be used as a context manager, and will yield
      +    a recording object with two attributes: `output` and `records`.
      +    At the end of the context manager, the `output` attribute will
      +    be a list of the matching formatted log messages and the
      +    `records` attribute will be a list of the corresponding LogRecord
      +    objects.
      +    Example::
      +        with self.assertLogs('foo', level='INFO') as cm:
      +            logging.getLogger('foo').info('first message')
      +            logging.getLogger('foo.bar').error('second message')
      +        self.assertEqual(cm.output, ['INFO:foo:first message',
      +                                     'ERROR:foo.bar:second message'])
      +    """
      +    return _AssertLogsContext(self, logger, level)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertMultiLineEqual(

      self, first, second, msg=None)

      +
      + + + + +

      Assert that two multi-line strings are equal.

      +
      + +
      +
      def assertMultiLineEqual(self, first, second, msg=None):
      +    """Assert that two multi-line strings are equal."""
      +    self.assertIsInstance(first, str, 'First argument is not a string')
      +    self.assertIsInstance(second, str, 'Second argument is not a string')
      +    if first != second:
      +        # don't use difflib if the strings are too long
      +        if (len(first) > self._diffThreshold or
      +            len(second) > self._diffThreshold):
      +            self._baseAssertEqual(first, second, msg)
      +        firstlines = first.splitlines(keepends=True)
      +        secondlines = second.splitlines(keepends=True)
      +        if len(firstlines) == 1 and first.strip('\r\n') == first:
      +            firstlines = [first + '\n']
      +            secondlines = [second + '\n']
      +        standardMsg = '%s != %s' % _common_shorten_repr(first, second)
      +        diff = '\n' + ''.join(difflib.ndiff(firstlines, secondlines))
      +        standardMsg = self._truncateMessage(standardMsg, diff)
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertNotAlmostEqual(

      self, first, second, places=None, msg=None, delta=None)

      +
      + + + + +

      Fail if the two objects are equal as determined by their +difference rounded to the given number of decimal places +(default 7) and comparing to zero, or by comparing that the +between the two objects is less than the given delta.

      +

      Note that decimal places (from zero) are usually not the same +as significant digits (measured from the most signficant digit).

      +

      Objects that are equal automatically fail.

      +
      + +
      +
      def assertNotAlmostEqual(self, first, second, places=None, msg=None,
      +                         delta=None):
      +    """Fail if the two objects are equal as determined by their
      +       difference rounded to the given number of decimal places
      +       (default 7) and comparing to zero, or by comparing that the
      +       between the two objects is less than the given delta.
      +       Note that decimal places (from zero) are usually not the same
      +       as significant digits (measured from the most signficant digit).
      +       Objects that are equal automatically fail.
      +    """
      +    if delta is not None and places is not None:
      +        raise TypeError("specify delta or places not both")
      +    if delta is not None:
      +        if not (first == second) and abs(first - second) > delta:
      +            return
      +        standardMsg = '%s == %s within %s delta' % (safe_repr(first),
      +                                                    safe_repr(second),
      +                                                    safe_repr(delta))
      +    else:
      +        if places is None:
      +            places = 7
      +        if not (first == second) and round(abs(second-first), places) != 0:
      +            return
      +        standardMsg = '%s == %s within %r places' % (safe_repr(first),
      +                                                     safe_repr(second),
      +                                                     places)
      +    msg = self._formatMessage(msg, standardMsg)
      +    raise self.failureException(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertNotAlmostEquals(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertNotEqual(

      self, first, second, msg=None)

      +
      + + + + +

      Fail if the two objects are equal as determined by the '!=' +operator.

      +
      + +
      +
      def assertNotEqual(self, first, second, msg=None):
      +    """Fail if the two objects are equal as determined by the '!='
      +       operator.
      +    """
      +    if not first != second:
      +        msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first),
      +                                                      safe_repr(second)))
      +        raise self.failureException(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertNotEquals(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertNotIn(

      self, member, container, msg=None)

      +
      + + + + +

      Just like self.assertTrue(a not in b), but with a nicer default message.

      +
      + +
      +
      def assertNotIn(self, member, container, msg=None):
      +    """Just like self.assertTrue(a not in b), but with a nicer default message."""
      +    if member in container:
      +        standardMsg = '%s unexpectedly found in %s' % (safe_repr(member),
      +                                                    safe_repr(container))
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertNotIsInstance(

      self, obj, cls, msg=None)

      +
      + + + + +

      Included for symmetry with assertIsInstance.

      +
      + +
      +
      def assertNotIsInstance(self, obj, cls, msg=None):
      +    """Included for symmetry with assertIsInstance."""
      +    if isinstance(obj, cls):
      +        standardMsg = '%s is an instance of %r' % (safe_repr(obj), cls)
      +        self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertNotRegex(

      self, text, unexpected_regex, msg=None)

      +
      + + + + +

      Fail the test if the text matches the regular expression.

      +
      + +
      +
      def assertNotRegex(self, text, unexpected_regex, msg=None):
      +    """Fail the test if the text matches the regular expression."""
      +    if isinstance(unexpected_regex, (str, bytes)):
      +        unexpected_regex = re.compile(unexpected_regex)
      +    match = unexpected_regex.search(text)
      +    if match:
      +        msg = msg or "Regex matched"
      +        msg = '%s: %r matches %r in %r' % (msg,
      +                                           text[match.start():match.end()],
      +                                           unexpected_regex.pattern,
      +                                           text)
      +        raise self.failureException(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      +
      + + + + +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is +raised, it will not be caught, and the test case will be +deemed to have suffered an error, exactly as for an +unexpected exception.

      +

      If called with callableObj omitted or None, will return a +context object used like this::

      +
       with self.assertRaises(SomeException):
      +     do_something()
      +
      + + +

      An optional keyword argument 'msg' can be provided when assertRaises +is used as a context object.

      +

      The context manager keeps a reference to the exception as +the 'exception' attribute. This allows you to inspect the +exception after the assertion::

      +
      with self.assertRaises(SomeException) as cm:
      +    do_something()
      +the_exception = cm.exception
      +self.assertEqual(the_exception.error_code, 3)
      +
      +
      + +
      +
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
      +       raised, it will not be caught, and the test case will be
      +       deemed to have suffered an error, exactly as for an
      +       unexpected exception.
      +       If called with callableObj omitted or None, will return a
      +       context object used like this::
      +            with self.assertRaises(SomeException):
      +                do_something()
      +       An optional keyword argument 'msg' can be provided when assertRaises
      +       is used as a context object.
      +       The context manager keeps a reference to the exception as
      +       the 'exception' attribute. This allows you to inspect the
      +       exception after the assertion::
      +           with self.assertRaises(SomeException) as cm:
      +               do_something()
      +           the_exception = cm.exception
      +           self.assertEqual(the_exception.error_code, 3)
      +    """
      +    context = _AssertRaisesContext(excClass, self, callableObj)
      +    return context.handle('assertRaises', callableObj, args, kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      +
      + + + + +

      Asserts that the message in a raised exception matches a regex.

      +

      Args: + expected_exception: Exception class expected to be raised. + expected_regex: Regex (re pattern object or string) expected + to be found in error message. + callable_obj: Function to be called. + msg: Optional message used in case of failure. Can only be used + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      +
      + +
      +
      def assertRaisesRegex(self, expected_exception, expected_regex,
      +                      callable_obj=None, *args, **kwargs):
      +    """Asserts that the message in a raised exception matches a regex.
      +    Args:
      +        expected_exception: Exception class expected to be raised.
      +        expected_regex: Regex (re pattern object or string) expected
      +                to be found in error message.
      +        callable_obj: Function to be called.
      +        msg: Optional message used in case of failure. Can only be used
      +                when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
      +    """
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertRaisesRegexp(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertRegex(

      self, text, expected_regex, msg=None)

      +
      + + + + +

      Fail the test unless the text matches the regular expression.

      +
      + +
      +
      def assertRegex(self, text, expected_regex, msg=None):
      +    """Fail the test unless the text matches the regular expression."""
      +    if isinstance(expected_regex, (str, bytes)):
      +        assert expected_regex, "expected_regex must not be empty."
      +        expected_regex = re.compile(expected_regex)
      +    if not expected_regex.search(text):
      +        msg = msg or "Regex didn't match"
      +        msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
      +        raise self.failureException(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertRegexpMatches(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertSequenceEqual(

      self, seq1, seq2, msg=None, seq_type=None)

      +
      + + + + +

      An equality assertion for ordered sequences (like lists and tuples).

      +

      For the purposes of this function, a valid ordered sequence type is one +which can be indexed, has a length, and has an equality operator.

      +

      Args: + seq1: The first sequence to compare. + seq2: The second sequence to compare. + seq_type: The expected datatype of the sequences, or None if no + datatype should be enforced. + msg: Optional message to use on failure instead of a list of + differences.

      +
      + +
      +
      def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
      +    """An equality assertion for ordered sequences (like lists and tuples).
      +    For the purposes of this function, a valid ordered sequence type is one
      +    which can be indexed, has a length, and has an equality operator.
      +    Args:
      +        seq1: The first sequence to compare.
      +        seq2: The second sequence to compare.
      +        seq_type: The expected datatype of the sequences, or None if no
      +                datatype should be enforced.
      +        msg: Optional message to use on failure instead of a list of
      +                differences.
      +    """
      +    if seq_type is not None:
      +        seq_type_name = seq_type.__name__
      +        if not isinstance(seq1, seq_type):
      +            raise self.failureException('First sequence is not a %s: %s'
      +                                    % (seq_type_name, safe_repr(seq1)))
      +        if not isinstance(seq2, seq_type):
      +            raise self.failureException('Second sequence is not a %s: %s'
      +                                    % (seq_type_name, safe_repr(seq2)))
      +    else:
      +        seq_type_name = "sequence"
      +    differing = None
      +    try:
      +        len1 = len(seq1)
      +    except (TypeError, NotImplementedError):
      +        differing = 'First %s has no length.    Non-sequence?' % (
      +                seq_type_name)
      +    if differing is None:
      +        try:
      +            len2 = len(seq2)
      +        except (TypeError, NotImplementedError):
      +            differing = 'Second %s has no length.    Non-sequence?' % (
      +                    seq_type_name)
      +    if differing is None:
      +        if seq1 == seq2:
      +            return
      +        differing = '%ss differ: %s != %s\n' % (
      +                (seq_type_name.capitalize(),) +
      +                _common_shorten_repr(seq1, seq2))
      +        for i in range(min(len1, len2)):
      +            try:
      +                item1 = seq1[i]
      +            except (TypeError, IndexError, NotImplementedError):
      +                differing += ('\nUnable to index element %d of first %s\n' %
      +                             (i, seq_type_name))
      +                break
      +            try:
      +                item2 = seq2[i]
      +            except (TypeError, IndexError, NotImplementedError):
      +                differing += ('\nUnable to index element %d of second %s\n' %
      +                             (i, seq_type_name))
      +                break
      +            if item1 != item2:
      +                differing += ('\nFirst differing element %d:\n%s\n%s\n' %
      +                             (i, item1, item2))
      +                break
      +        else:
      +            if (len1 == len2 and seq_type is None and
      +                type(seq1) != type(seq2)):
      +                # The sequences are the same, but have differing types.
      +                return
      +        if len1 > len2:
      +            differing += ('\nFirst %s contains %d additional '
      +                         'elements.\n' % (seq_type_name, len1 - len2))
      +            try:
      +                differing += ('First extra element %d:\n%s\n' %
      +                              (len2, seq1[len2]))
      +            except (TypeError, IndexError, NotImplementedError):
      +                differing += ('Unable to index element %d '
      +                              'of first %s\n' % (len2, seq_type_name))
      +        elif len1 < len2:
      +            differing += ('\nSecond %s contains %d additional '
      +                         'elements.\n' % (seq_type_name, len2 - len1))
      +            try:
      +                differing += ('First extra element %d:\n%s\n' %
      +                              (len1, seq2[len1]))
      +            except (TypeError, IndexError, NotImplementedError):
      +                differing += ('Unable to index element %d '
      +                              'of second %s\n' % (len1, seq_type_name))
      +    standardMsg = differing
      +    diffMsg = '\n' + '\n'.join(
      +        difflib.ndiff(pprint.pformat(seq1).splitlines(),
      +                      pprint.pformat(seq2).splitlines()))
      +    standardMsg = self._truncateMessage(standardMsg, diffMsg)
      +    msg = self._formatMessage(msg, standardMsg)
      +    self.fail(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertSetEqual(

      self, set1, set2, msg=None)

      +
      + + + + +

      A set-specific equality assertion.

      +

      Args: + set1: The first set to compare. + set2: The second set to compare. + msg: Optional message to use on failure instead of a list of + differences.

      +

      assertSetEqual uses ducktyping to support different types of sets, and +is optimized for sets specifically (parameters must support a +difference method).

      +
      + +
      +
      def assertSetEqual(self, set1, set2, msg=None):
      +    """A set-specific equality assertion.
      +    Args:
      +        set1: The first set to compare.
      +        set2: The second set to compare.
      +        msg: Optional message to use on failure instead of a list of
      +                differences.
      +    assertSetEqual uses ducktyping to support different types of sets, and
      +    is optimized for sets specifically (parameters must support a
      +    difference method).
      +    """
      +    try:
      +        difference1 = set1.difference(set2)
      +    except TypeError as e:
      +        self.fail('invalid type when attempting set difference: %s' % e)
      +    except AttributeError as e:
      +        self.fail('first argument does not support set difference: %s' % e)
      +    try:
      +        difference2 = set2.difference(set1)
      +    except TypeError as e:
      +        self.fail('invalid type when attempting set difference: %s' % e)
      +    except AttributeError as e:
      +        self.fail('second argument does not support set difference: %s' % e)
      +    if not (difference1 or difference2):
      +        return
      +    lines = []
      +    if difference1:
      +        lines.append('Items in the first set but not the second:')
      +        for item in difference1:
      +            lines.append(repr(item))
      +    if difference2:
      +        lines.append('Items in the second set but not the first:')
      +        for item in difference2:
      +            lines.append(repr(item))
      +    standardMsg = '\n'.join(lines)
      +    self.fail(self._formatMessage(msg, standardMsg))
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertTrue(

      self, expr, msg=None)

      +
      + + + + +

      Check that the expression is true.

      +
      + +
      +
      def assertTrue(self, expr, msg=None):
      +    """Check that the expression is true."""
      +    if not expr:
      +        msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr))
      +        raise self.failureException(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertTupleEqual(

      self, tuple1, tuple2, msg=None)

      +
      + + + + +

      A tuple-specific equality assertion.

      +

      Args: + tuple1: The first tuple to compare. + tuple2: The second tuple to compare. + msg: Optional message to use on failure instead of a list of + differences.

      +
      + +
      +
      def assertTupleEqual(self, tuple1, tuple2, msg=None):
      +    """A tuple-specific equality assertion.
      +    Args:
      +        tuple1: The first tuple to compare.
      +        tuple2: The second tuple to compare.
      +        msg: Optional message to use on failure instead of a list of
      +                differences.
      +    """
      +    self.assertSequenceEqual(tuple1, tuple2, msg, seq_type=tuple)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      +
      + + + + +

      Fail unless a warning of class warnClass is triggered +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is +triggered, it will not be handled: depending on the other +warning filtering rules in effect, it might be silenced, printed +out, or raised as an exception.

      +

      If called with callable_obj omitted or None, will return a +context object used like this::

      +
       with self.assertWarns(SomeWarning):
      +     do_something()
      +
      + + +

      An optional keyword argument 'msg' can be provided when assertWarns +is used as a context object.

      +

      The context manager keeps a reference to the first matching +warning as the 'warning' attribute; similarly, the 'filename' +and 'lineno' attributes give you information about the line +of Python code from which the warning was triggered. +This allows you to inspect the warning after the assertion::

      +
      with self.assertWarns(SomeWarning) as cm:
      +    do_something()
      +the_warning = cm.warning
      +self.assertEqual(the_warning.some_attribute, 147)
      +
      +
      + +
      +
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
      +    """Fail unless a warning of class warnClass is triggered
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
      +       triggered, it will not be handled: depending on the other
      +       warning filtering rules in effect, it might be silenced, printed
      +       out, or raised as an exception.
      +       If called with callable_obj omitted or None, will return a
      +       context object used like this::
      +            with self.assertWarns(SomeWarning):
      +                do_something()
      +       An optional keyword argument 'msg' can be provided when assertWarns
      +       is used as a context object.
      +       The context manager keeps a reference to the first matching
      +       warning as the 'warning' attribute; similarly, the 'filename'
      +       and 'lineno' attributes give you information about the line
      +       of Python code from which the warning was triggered.
      +       This allows you to inspect the warning after the assertion::
      +           with self.assertWarns(SomeWarning) as cm:
      +               do_something()
      +           the_warning = cm.warning
      +           self.assertEqual(the_warning.some_attribute, 147)
      +    """
      +    context = _AssertWarnsContext(expected_warning, self, callable_obj)
      +    return context.handle('assertWarns', callable_obj, args, kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      +
      + + + + +

      Asserts that the message in a triggered warning matches a regexp. +Basic functioning is similar to assertWarns() with the addition +that only warnings whose messages also match the regular expression +are considered successful matches.

      +

      Args: + expected_warning: Warning class expected to be triggered. + expected_regex: Regex (re pattern object or string) expected + to be found in error message. + callable_obj: Function to be called. + msg: Optional message used in case of failure. Can only be used + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      +
      + +
      +
      def assertWarnsRegex(self, expected_warning, expected_regex,
      +                     callable_obj=None, *args, **kwargs):
      +    """Asserts that the message in a triggered warning matches a regexp.
      +    Basic functioning is similar to assertWarns() with the addition
      +    that only warnings whose messages also match the regular expression
      +    are considered successful matches.
      +    Args:
      +        expected_warning: Warning class expected to be triggered.
      +        expected_regex: Regex (re pattern object or string) expected
      +                to be found in error message.
      +        callable_obj: Function to be called.
      +        msg: Optional message used in case of failure. Can only be used
      +                when assertWarnsRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
      +    """
      +    context = _AssertWarnsContext(expected_warning, self, callable_obj,
      +                                  expected_regex)
      +    return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def assert_(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def countTestCases(

      self)

      +
      + + + + +
      + +
      +
      def countTestCases(self):
      +    return 1
      +
      + +
      +
      + +
      + + +
      +
      +

      def debug(

      self)

      +
      + + + + +

      Run the test without collecting errors in a TestResult

      +
      + +
      +
      def debug(self):
      +    """Run the test without collecting errors in a TestResult"""
      +    self.setUp()
      +    getattr(self, self._testMethodName)()
      +    self.tearDown()
      +    while self._cleanups:
      +        function, args, kwargs = self._cleanups.pop(-1)
      +        function(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def defaultTestResult(

      self)

      +
      + + + + +
      + +
      +
      def defaultTestResult(self):
      +    return result.TestResult()
      +
      + +
      +
      + +
      + + +
      +
      +

      def doCleanups(

      self)

      +
      + + + + +

      Execute all cleanup functions. Normally called for you after +tearDown.

      +
      + +
      +
      def doCleanups(self):
      +    """Execute all cleanup functions. Normally called for you after
      +    tearDown."""
      +    outcome = self._outcome or _Outcome()
      +    while self._cleanups:
      +        function, args, kwargs = self._cleanups.pop()
      +        with outcome.testPartExecutor(self):
      +            function(*args, **kwargs)
      +    # return this for backwards compatibility
      +    # even though we no longer us it internally
      +    return outcome.success
      +
      + +
      +
      + +
      + + +
      +
      +

      def fail(

      self, msg=None)

      +
      + + + + +

      Fail immediately, with the given message.

      +
      + +
      +
      def fail(self, msg=None):
      +    """Fail immediately, with the given message."""
      +    raise self.failureException(msg)
      +
      + +
      +
      + +
      + + +
      +
      +

      def failIf(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def failIfAlmostEqual(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def failIfEqual(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def failUnless(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def failUnlessAlmostEqual(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def failUnlessEqual(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def failUnlessRaises(

      *args, **kwargs)

      +
      + + + + +
      + +
      +
      def deprecated_func(*args, **kwargs):
      +    warnings.warn(
      +        'Please use {0} instead.'.format(original_func.__name__),
      +        DeprecationWarning, 2)
      +    return original_func(*args, **kwargs)
      +
      + +
      +
      + +
      + + +
      +
      +

      def id(

      self)

      +
      + + + + +
      + +
      +
      def id(self):
      +    return "%s.%s" % (strclass(self.__class__), self._testMethodName)
      +
      + +
      +
      + +
      + + +
      +
      +

      def run(

      self, result=None)

      +
      + + + + +
      + +
      +
      def run(self, result=None):
      +    orig_result = result
      +    if result is None:
      +        result = self.defaultTestResult()
      +        startTestRun = getattr(result, 'startTestRun', None)
      +        if startTestRun is not None:
      +            startTestRun()
      +    result.startTest(self)
      +    testMethod = getattr(self, self._testMethodName)
      +    if (getattr(self.__class__, "__unittest_skip__", False) or
      +        getattr(testMethod, "__unittest_skip__", False)):
      +        # If the class or method was skipped.
      +        try:
      +            skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
      +                        or getattr(testMethod, '__unittest_skip_why__', ''))
      +            self._addSkip(result, self, skip_why)
      +        finally:
      +            result.stopTest(self)
      +        return
      +    expecting_failure_method = getattr(testMethod,
      +                                       "__unittest_expecting_failure__", False)
      +    expecting_failure_class = getattr(self,
      +                                      "__unittest_expecting_failure__", False)
      +    expecting_failure = expecting_failure_class or expecting_failure_method
      +    outcome = _Outcome(result)
      +    try:
      +        self._outcome = outcome
      +        with outcome.testPartExecutor(self):
      +            self.setUp()
      +        if outcome.success:
      +            outcome.expecting_failure = expecting_failure
      +            with outcome.testPartExecutor(self, isTest=True):
      +                testMethod()
      +            outcome.expecting_failure = False
      +            with outcome.testPartExecutor(self):
      +                self.tearDown()
      +        self.doCleanups()
      +        for test, reason in outcome.skipped:
      +            self._addSkip(result, test, reason)
      +        self._feedErrorsToResult(result, outcome.errors)
      +        if outcome.success:
      +            if expecting_failure:
      +                if outcome.expectedFailure:
      +                    self._addExpectedFailure(result, outcome.expectedFailure)
      +                else:
      +                    self._addUnexpectedSuccess(result)
      +            else:
      +                result.addSuccess(self)
      +        return result
      +    finally:
      +        result.stopTest(self)
      +        if orig_result is None:
      +            stopTestRun = getattr(result, 'stopTestRun', None)
      +            if stopTestRun is not None:
      +                stopTestRun()
      +        # explicitly break reference cycles:
      +        # outcome.errors -> frame -> outcome -> outcome.errors
      +        # outcome.expectedFailure -> frame -> outcome -> outcome.expectedFailure
      +        outcome.errors.clear()
      +        outcome.expectedFailure = None
      +        # clear the outcome, no more needed
      +        self._outcome = None
      +
      + +
      +
      + +
      + + +
      +
      +

      def setUp(

      self)

      +
      + + + + +
      + +
      +
      def setUp(self):
      +    data = {"Bob": {"author": 'Bob',
      +                    "email": 'bob@gmail.com',
      +                    "type": 'author'},
      +            "Bobby": {"author": 'Bobby',
      +                      "email": 'bob@gmail.com',
      +                      "type": 'author'},
      +            "Robert": {"author": 'Robert',
      +                       "email": 'bob@gmail.com',
      +                       "type": 'author'}}
      +    self.log = gitnet.Log(data)
      +
      + +
      +
      + +
      + + +
      +
      +

      def shortDescription(

      self)

      +
      + + + + +

      Returns a one-line description of the test, or None if no +description has been provided.

      +

      The default implementation of this method returns the first line of +the specified test method's docstring.

      +
      + +
      +
      def shortDescription(self):
      +    """Returns a one-line description of the test, or None if no
      +    description has been provided.
      +    The default implementation of this method returns the first line of
      +    the specified test method's docstring.
      +    """
      +    doc = self._testMethodDoc
      +    return doc and doc.split("\n")[0].strip() or None
      +
      + +
      +
      + +
      + + +
      +
      +

      def skipTest(

      self, reason)

      +
      + + + + +

      Skip this test.

      +
      + +
      +
      def skipTest(self, reason):
      +    """Skip this test."""
      +    raise SkipTest(reason)
      +
      + +
      +
      + +
      + + +
      +
      +

      def subTest(

      *args, **kwds)

      +
      + + + + +

      Return a context manager that will return the enclosed block +of code in a subtest identified by the optional message and +keyword parameters. A failure in the subtest marks the test +case as failed but resumes execution at the end of the enclosed +block, allowing further test code to be executed.

      +
      + +
      @contextlib.contextmanager
       def subTest(self, msg=None, **params):
           """Return a context manager that will return the enclosed block
      @@ -17851,7 +20053,6 @@ 

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -18074,31 +20275,6 @@

      Methods

      class FilterTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -19307,12 +21483,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -19322,45 +21497,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -19380,14 +21531,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -19401,8 +21552,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -19413,7 +21564,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -19424,27 +21575,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -19495,10 +21649,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -19773,19 +21925,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -19807,14 +21959,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -19830,8 +21982,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -19842,7 +21994,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -19856,15 +22008,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -19873,13 +22026,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -20315,7 +22470,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -20828,31 +22982,6 @@

      Methods

      class GenEdgesTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -22031,12 +24160,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -22046,45 +24174,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -22104,14 +24208,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -22125,8 +24229,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -22137,7 +24241,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -22148,27 +24252,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -22219,10 +24326,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -22497,19 +24602,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -22531,14 +24636,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -22554,8 +24659,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -22566,7 +24671,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -22580,15 +24685,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -22597,13 +24703,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -23039,7 +25147,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -23174,7 +25281,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -23430,31 +25536,6 @@

      Methods

      class GenNetworkTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -24586,12 +26667,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -24601,45 +26681,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -24659,14 +26715,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -24680,8 +26736,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -24692,7 +26748,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -24703,27 +26759,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -24774,10 +26833,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -25052,19 +27109,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -25086,14 +27143,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -25109,8 +27166,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -25121,7 +27178,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -25135,15 +27192,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -25152,13 +27210,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -25594,7 +27654,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -25728,7 +27787,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -25929,31 +27987,6 @@

      Methods

      class GenNodesTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -27255,12 +29288,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -27270,45 +29302,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -27328,14 +29336,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -27349,8 +29357,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -27361,7 +29369,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -27372,27 +29380,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -27443,10 +29454,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -27721,19 +29730,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -27755,14 +29764,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -27778,8 +29787,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -27790,7 +29799,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -27804,15 +29813,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -27821,13 +29831,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -28263,7 +30275,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -28419,7 +30430,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -28801,31 +30811,6 @@

      Methods

      class GetTagsTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -29879,12 +31864,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -29894,45 +31878,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -29952,14 +31912,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -29973,8 +31933,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -29985,7 +31945,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -29996,27 +31956,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -30067,10 +32030,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -30345,19 +32306,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -30379,14 +32340,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -30402,8 +32363,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -30414,7 +32375,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -30428,15 +32389,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -30445,13 +32407,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -30887,7 +32851,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -31115,31 +33078,6 @@

      Methods

      class MagicMethodTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -32200,12 +34138,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -32215,45 +34152,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -32273,14 +34186,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -32294,8 +34207,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -32306,7 +34219,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -32317,27 +34230,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -32388,10 +34304,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -32666,19 +34580,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -32700,14 +34614,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -32723,8 +34637,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -32735,7 +34649,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -32749,15 +34663,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -32766,13 +34681,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -33208,7 +35125,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -33341,7 +35257,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -34561,12 +36476,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -34576,45 +36490,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -34634,14 +36524,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -34655,8 +36545,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -34667,7 +36557,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -34678,27 +36568,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -34749,10 +36642,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -35027,19 +36918,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -35061,14 +36952,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -35084,8 +36975,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -35096,7 +36987,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -35110,15 +37001,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -35127,13 +37019,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -35569,7 +37463,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -35702,7 +37595,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -35895,31 +37787,6 @@

      Methods

      class TsvTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -35943,7 +37810,7 @@

      Methods

      # Setting up the directory for the tsv self.made_tsv = False try: - self.tsv_str = self.log.tsv(fname='temp.tsv') + self.tsv_str = self.log.tsv('temp.tsv') self.path = os.getcwd() + '/temp.tsv' finally: self.made_tsv = True @@ -35955,7 +37822,7 @@

      Methods

      # Check that a file exists where expected self.assertTrue(os.path.exists(self.path)) # Check a summary string is produced - self.assertEqual("Data written to temp.tsv", self.tsv_str) + self.assertIn("Data written to temp.tsv", self.tsv_str) def test_basic_nofn(self): """Is no file produced but a string given? """ @@ -35965,16 +37832,16 @@

      Methods

      # Checking no file is created self.assertFalse(os.path.exists(self.path)) # Checking a correct string is returned - tsv_str = self.log.tsv() + tsv_str = self.log.tsv('temp.tsv') self.assertIsInstance(tsv_str, str) - self.assertIn('\t', tsv_str) + self.assertIn('t', tsv_str) def test_empty_cols(self): - tsv_str = self.log.tsv(empty_cols=True, fname='temp.tsv') + tsv_str = self.log.tsv('temp.tsv', empty_cols=True) # Checking file is created self.assertTrue(os.path.exists(self.path)) # Check a summary string is produced - self.assertEqual("Data written to temp.tsv", tsv_str) + self.assertIn("Data written to temp.tsv", tsv_str) def test_warnings(self): # Warning occurs non string values are forced to strings @@ -35982,7 +37849,7 @@

      Methods

      # Ensure warnings are being shown warnings.simplefilter("always") # Trigger Warning - self.log.tsv() + self.log.tsv('temp.tsv') # Check Warning occurred self.assertIn("Non-string input forced to string", str(w[-1].message)) @@ -37025,12 +38892,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -37040,45 +38906,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -37098,14 +38940,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -37119,8 +38961,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -37131,7 +38973,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -37142,27 +38984,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -37213,10 +39058,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -37491,19 +39334,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -37525,14 +39368,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -37548,8 +39391,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -37560,7 +39403,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -37574,15 +39417,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -37591,13 +39435,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -38033,7 +39879,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -38055,7 +39900,7 @@

      Static methods

      # Setting up the directory for the tsv self.made_tsv = False try: - self.tsv_str = self.log.tsv(fname='temp.tsv') + self.tsv_str = self.log.tsv('temp.tsv') self.path = os.getcwd() + '/temp.tsv' finally: self.made_tsv = True @@ -38183,7 +40028,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -38217,7 +40061,7 @@

      Static methods

      # Check that a file exists where expected self.assertTrue(os.path.exists(self.path)) # Check a summary string is produced - self.assertEqual("Data written to temp.tsv", self.tsv_str) + self.assertIn("Data written to temp.tsv", self.tsv_str)
      @@ -38246,9 +40090,9 @@

      Static methods

      # Checking no file is created self.assertFalse(os.path.exists(self.path)) # Checking a correct string is returned - tsv_str = self.log.tsv() + tsv_str = self.log.tsv('temp.tsv') self.assertIsInstance(tsv_str, str) - self.assertIn('\t', tsv_str) + self.assertIn('t', tsv_str)
      @@ -38269,11 +40113,11 @@

      Static methods

      def test_empty_cols(self):
      -    tsv_str = self.log.tsv(empty_cols=True, fname='temp.tsv')
      +    tsv_str = self.log.tsv('temp.tsv', empty_cols=True)
           # Checking file is created
           self.assertTrue(os.path.exists(self.path))
           # Check a summary string is produced
      -    self.assertEqual("Data written to temp.tsv", tsv_str)
      +    self.assertIn("Data written to temp.tsv", tsv_str)
       
      @@ -38299,7 +40143,7 @@

      Static methods

      # Ensure warnings are being shown warnings.simplefilter("always") # Trigger Warning - self.log.tsv() + self.log.tsv('temp.tsv') # Check Warning occurred self.assertIn("Non-string input forced to string", str(w[-1].message))
      @@ -38363,31 +40207,6 @@

      Methods

      class VectorTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -39469,12 +41288,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -39484,45 +41302,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -39542,14 +41336,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -39563,8 +41357,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -39575,7 +41369,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -39586,27 +41380,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -39657,10 +41454,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -39935,19 +41730,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -39969,14 +41764,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -39992,8 +41787,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -40004,7 +41799,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -40018,15 +41813,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -40035,13 +41831,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -40477,7 +42275,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -40771,31 +42568,6 @@

      Methods

      class WriteEdgesTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -40913,7 +42685,7 @@

      Methods

      # Delete our temporary written edges file if self.made_edges: - sub.call(['rm', 'temp_edges.txt']) + sub.call(['rm', '-rf', 'temp_edges.txt'])
      @@ -41950,12 +43722,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -41965,45 +43736,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -42023,14 +43770,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -42044,8 +43791,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -42056,7 +43803,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -42067,27 +43814,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -42138,10 +43888,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -42416,19 +44164,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -42450,14 +44198,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -42473,8 +44221,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -42485,7 +44233,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -42499,15 +44247,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -42516,13 +44265,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -42958,7 +44709,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -43098,7 +44848,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -43107,7 +44856,7 @@

      Static methods

      sub.call(["rm", "-rf", ".git"]) # Delete our temporary written edges file if self.made_edges: - sub.call(['rm', 'temp_edges.txt']) + sub.call(['rm', '-rf', 'temp_edges.txt'])
      @@ -43326,31 +45075,6 @@

      Methods

      class WriteNodesTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -44446,12 +46170,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -44461,45 +46184,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -44519,14 +46218,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -44540,8 +46239,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -44552,7 +46251,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -44563,27 +46262,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -44634,10 +46336,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -44912,19 +46612,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -44946,14 +46646,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -44969,8 +46669,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -44981,7 +46681,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -44995,15 +46695,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -45012,13 +46713,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -45454,7 +47157,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -45595,7 +47297,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      diff --git a/docs/gitnet/gitnet_tests/test_netgen.m.html b/docs/gitnet/gitnet_tests/test_netgen.m.html index 3c63823..52c404e 100644 --- a/docs/gitnet/gitnet_tests/test_netgen.m.html +++ b/docs/gitnet/gitnet_tests/test_netgen.m.html @@ -1076,7 +1076,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1154,7 +1153,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1187,8 +1185,11 @@

      Index

    • subTest
    • tearDown
    • test_author_file
    • +
    • test_complex_colours
    • test_file_author
    • test_hash_author
    • +
    • test_no_colours
    • +
    • test_simple_colours
    • test_tag_warning
    • setUpClass
    • tearDownClass
    • @@ -1231,7 +1232,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1500,11 +1500,33 @@

      gitnet.gitnet_tests.test_netgen modu self.assertEqual(n[1],net2.node[n[0]]) self.assertEqual(len(net),len(net2)) + def test_no_colours(self): + net = self.my_log.generate_network('author', 'files', colours=None) + nodes = str(net.nodes(data=True)) + print(nodes) + self.assertIn('Bob' and 'Alice', nodes) + # self.assertIn(not 'colour', nodes) + # self.assertIn(not 'lightcoral', nodes) + # self.assertIn(not 'oldlace', nodes) + # Need a way to assert that certain strings are NOT in the record. + + def test_simple_colours(self): + net = self.my_log.generate_network('author', 'files', colours='simple') + nodes = str(net.nodes(data=True)) + self.assertIn("'id': 'readme.md'" and "'type': 'files'" and "'colour': 'lightcoral'", nodes) + self.assertIn("'id': 'Alice'" and "'type': 'author'" and "'colour': 'oldlace'", nodes) + + def test_complex_colours(self): + net = self.my_log.generate_network('author', 'files', colours='complex') + nodes = str(net.nodes(data=True)) + self.assertIn("'id': 'readme.md'" and "'type': 'files'" and "'colour': 'lightgrey'", nodes) + self.assertIn("'id': 'Alice'" and "'type': 'author'" and "'colour': 'oldlace'", nodes) + def tearDown(self): sub.call(["rm","-rf",".git"]) if __name__ == '__main__': - unittest.main(buffer=False) + unittest.main(buffer=True)

      @@ -1520,31 +1542,6 @@

      Classes

      class TestEdgeGeneratorSmall

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -2628,12 +2625,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -2643,45 +2639,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -2701,14 +2673,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -2722,8 +2694,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -2734,7 +2706,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -2745,27 +2717,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -2816,10 +2791,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -3094,19 +3067,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -3128,14 +3101,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -3151,8 +3124,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -3163,7 +3136,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -3177,15 +3150,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -3194,13 +3168,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -3636,7 +3612,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -3769,7 +3744,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -3959,31 +3933,6 @@

      Methods

      class TestNetworkGeneratorSmall

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -4056,6 +4005,28 @@

      Methods

      self.assertEqual(n[1],net2.node[n[0]]) self.assertEqual(len(net),len(net2)) + def test_no_colours(self): + net = self.my_log.generate_network('author', 'files', colours=None) + nodes = str(net.nodes(data=True)) + print(nodes) + self.assertIn('Bob' and 'Alice', nodes) + # self.assertIn(not 'colour', nodes) + # self.assertIn(not 'lightcoral', nodes) + # self.assertIn(not 'oldlace', nodes) + # Need a way to assert that certain strings are NOT in the record. + + def test_simple_colours(self): + net = self.my_log.generate_network('author', 'files', colours='simple') + nodes = str(net.nodes(data=True)) + self.assertIn("'id': 'readme.md'" and "'type': 'files'" and "'colour': 'lightcoral'", nodes) + self.assertIn("'id': 'Alice'" and "'type': 'author'" and "'colour': 'oldlace'", nodes) + + def test_complex_colours(self): + net = self.my_log.generate_network('author', 'files', colours='complex') + nodes = str(net.nodes(data=True)) + self.assertIn("'id': 'readme.md'" and "'type': 'files'" and "'colour': 'lightgrey'", nodes) + self.assertIn("'id': 'Alice'" and "'type': 'author'" and "'colour': 'oldlace'", nodes) + def tearDown(self): sub.call(["rm","-rf",".git"])
      @@ -5094,12 +5065,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -5109,45 +5079,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -5167,14 +5113,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -5188,8 +5134,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -5200,7 +5146,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -5211,27 +5157,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -5282,10 +5231,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -5560,19 +5507,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -5594,14 +5541,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -5617,8 +5564,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -5629,7 +5576,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -5643,15 +5590,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -5660,13 +5608,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -6102,7 +6052,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -6235,7 +6184,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -6307,6 +6255,30 @@

      Static methods

      +
      +
      +

      def test_complex_colours(

      self)

      +
      + + + + +
      + +
      +
      def test_complex_colours(self):
      +    net = self.my_log.generate_network('author', 'files', colours='complex')
      +    nodes = str(net.nodes(data=True))
      +    self.assertIn("'id': 'readme.md'" and "'type': 'files'" and "'colour': 'lightgrey'", nodes)
      +    self.assertIn("'id': 'Alice'" and "'type': 'author'" and "'colour': 'oldlace'", nodes)
      +
      + +
      +
      + +
      + +

      def test_file_author(

      self)

      @@ -6353,6 +6325,54 @@

      Static methods

      +
      +
      +

      def test_no_colours(

      self)

      +
      + + + + +
      + +
      +
      def test_no_colours(self):
      +    net = self.my_log.generate_network('author', 'files', colours=None)
      +    nodes = str(net.nodes(data=True))
      +    print(nodes)
      +    self.assertIn('Bob' and 'Alice', nodes)
      +
      + +
      +
      + +
      + + +
      +
      +

      def test_simple_colours(

      self)

      +
      + + + + +
      + +
      +
      def test_simple_colours(self):
      +    net = self.my_log.generate_network('author', 'files', colours='simple')
      +    nodes = str(net.nodes(data=True))
      +    self.assertIn("'id': 'readme.md'" and "'type': 'files'" and "'colour': 'lightcoral'", nodes)
      +    self.assertIn("'id': 'Alice'" and "'type': 'author'" and "'colour': 'oldlace'", nodes)
      +
      + +
      +
      + +
      + +

      def test_tag_warning(

      self)

      @@ -6435,31 +6455,6 @@

      Methods

      class TestNodeGeneratorSmall

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -7570,12 +7565,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -7585,45 +7579,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -7643,14 +7613,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -7664,8 +7634,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -7676,7 +7646,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -7687,27 +7657,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -7758,10 +7731,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -8036,19 +8007,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -8070,14 +8041,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -8093,8 +8064,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -8105,7 +8076,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -8119,15 +8090,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -8136,13 +8108,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -8578,7 +8552,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -8711,7 +8684,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      diff --git a/docs/gitnet/gitnet_tests/test_network.m.html b/docs/gitnet/gitnet_tests/test_network.m.html index dc5e8b6..d71a237 100644 --- a/docs/gitnet/gitnet_tests/test_network.m.html +++ b/docs/gitnet/gitnet_tests/test_network.m.html @@ -1076,7 +1076,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1155,7 +1154,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1231,7 +1229,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1309,7 +1306,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1384,7 +1380,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1468,7 +1463,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -1545,7 +1539,6 @@

      Index

    • assertNotIn
    • assertNotIsInstance
    • assertNotRegex
    • -
    • assertNotRegexpMatches
    • assertRaises
    • assertRaisesRegex
    • assertRaisesRegexp
    • @@ -3742,12 +3735,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -3757,45 +3749,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -3815,14 +3783,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -3836,8 +3804,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -3848,7 +3816,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -3859,27 +3827,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -3930,10 +3901,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -4208,19 +4177,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -4242,14 +4211,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -4265,8 +4234,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -4277,7 +4246,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -4291,15 +4260,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -4308,13 +4278,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -4750,7 +4722,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -6279,12 +6250,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -6294,45 +6264,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -6352,14 +6298,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -6373,8 +6319,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -6385,7 +6331,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -6396,27 +6342,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -6467,10 +6416,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -6745,19 +6692,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -6779,14 +6726,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -6802,8 +6749,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -6814,7 +6761,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -6828,15 +6775,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -6845,13 +6793,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -7287,7 +7237,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -7421,7 +7370,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -7566,31 +7514,6 @@

      Methods

      class GraphMLTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -8794,12 +8717,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -8809,45 +8731,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -8867,14 +8765,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -8888,8 +8786,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -8900,7 +8798,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -8911,27 +8809,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -8982,10 +8883,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -9260,19 +9159,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -9294,14 +9193,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -9317,8 +9216,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -9329,7 +9228,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -9343,15 +9242,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -9360,13 +9260,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -9961,7 +9863,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -10242,31 +10143,6 @@

      Methods

      class NodeAttrTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -11405,12 +11281,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -11420,45 +11295,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -11478,14 +11329,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -11499,8 +11350,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -11511,7 +11362,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -11522,27 +11373,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -11593,10 +11447,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -11871,19 +11723,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -11905,14 +11757,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -11928,8 +11780,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -11940,7 +11792,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -11954,15 +11806,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -11971,13 +11824,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -12413,7 +12268,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -13987,12 +13841,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -14002,45 +13855,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -14060,14 +13889,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -14081,8 +13910,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -14093,7 +13922,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -14104,27 +13933,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -14175,10 +14007,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -14453,19 +14283,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -14487,14 +14317,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -14510,8 +14340,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -14522,7 +14352,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -14536,15 +14366,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -14553,13 +14384,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -14995,7 +14828,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -16728,12 +16560,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -16743,45 +16574,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -16801,14 +16608,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -16822,8 +16629,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -16834,7 +16641,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -16845,27 +16652,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -16916,10 +16726,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -17194,19 +17002,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -17228,14 +17036,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -17251,8 +17059,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -17263,7 +17071,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -17277,15 +17085,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -17294,13 +17103,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -17736,7 +17547,6 @@

      Static methods

      -

      Hook method for setting up the test fixture before exercising it.

      @@ -17891,7 +17701,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      @@ -18081,31 +17890,6 @@

      Methods

      class TnetTests

      -

      A class whose instances are single test cases.

      -

      By default, the test code itself should be placed in a method named -'runTest'.

      -

      If the fixture may be used for many test cases, create as -many test methods as are needed. When instantiating such a TestCase -subclass, specify in the constructor arguments the name of the test method -that the instance is to execute.

      -

      Test authors should subclass TestCase for their own tests. Construction -and deconstruction of the test's environment ('fixture') can be -implemented by overriding the 'setUp' and 'tearDown' methods respectively.

      -

      If it is necessary to override the init method, the base class -init method must always be called. It is important that subclasses -should not change the signature of their init method, since instances -of the classes are instantiated automatically by parts of the framework -in order to be run.

      -

      When subclassing TestCase, you can set these attributes: - failureException: determines which exception will be raised when - the instance's assertion methods fail; test methods raising this - exception will be deemed to have 'failed' rather than 'errored'. - longMessage: determines whether long messages (including repr of - objects used in assert methods) will be printed on failure in addition - to any explicit message passed. -* maxDiff: sets the maximum length of a diff in failure messages - by assert methods using difflib. It is looked up as an instance - attribute so can be configured by individual tests if required.

      @@ -19279,12 +19063,11 @@

      Static methods

      unexpected_regex = re.compile(unexpected_regex) match = unexpected_regex.search(text) if match: - standardMsg = 'Regex matched: %r matches %r in %r' % ( - text[match.start() : match.end()], - unexpected_regex.pattern, - text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex matched" + msg = '%s: %r matches %r in %r' % (msg, + text[match.start():match.end()], + unexpected_regex.pattern, + text) raise self.failureException(msg)
      @@ -19294,45 +19077,21 @@

      Static methods

      -
      -
      -

      def assertNotRegexpMatches(

      *args, **kwargs)

      -
      - - - - -
      - -
      -
      def deprecated_func(*args, **kwargs):
      -    warnings.warn(
      -        'Please use {0} instead.'.format(original_func.__name__),
      -        DeprecationWarning, 2)
      -    return original_func(*args, **kwargs)
      -
      - -
      -
      - -
      - -
      -

      def assertRaises(

      self, expected_exception, *args, **kwargs)

      +

      def assertRaises(

      self, excClass, callableObj=None, *args, **kwargs)

      -

      Fail unless an exception of class expected_exception is raised -by the callable when invoked with specified positional and -keyword arguments. If a different type of exception is +

      Fail unless an exception of class excClass is raised +by callableObj when invoked with arguments args and keyword +arguments kwargs. If a different type of exception is raised, it will not be caught, and the test case will be deemed to have suffered an error, exactly as for an unexpected exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callableObj omitted or None, will return a context object used like this::

       with self.assertRaises(SomeException):
            do_something()
      @@ -19352,14 +19111,14 @@ 

      Static methods

      -
      def assertRaises(self, expected_exception, *args, **kwargs):
      -    """Fail unless an exception of class expected_exception is raised
      -       by the callable when invoked with specified positional and
      -       keyword arguments. If a different type of exception is
      +    
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
      +    """Fail unless an exception of class excClass is raised
      +       by callableObj when invoked with arguments args and keyword
      +       arguments kwargs. If a different type of exception is
              raised, it will not be caught, and the test case will be
              deemed to have suffered an error, exactly as for an
              unexpected exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callableObj omitted or None, will return a
              context object used like this::
                   with self.assertRaises(SomeException):
                       do_something()
      @@ -19373,8 +19132,8 @@ 

      Static methods

      the_exception = cm.exception self.assertEqual(the_exception.error_code, 3) """ - context = _AssertRaisesContext(expected_exception, self) - return context.handle('assertRaises', args, kwargs) + context = _AssertRaisesContext(excClass, self, callableObj) + return context.handle('assertRaises', callableObj, args, kwargs)
      @@ -19385,7 +19144,7 @@

      Static methods

      -

      def assertRaisesRegex(

      self, expected_exception, expected_regex, *args, **kwargs)

      +

      def assertRaisesRegex(

      self, expected_exception, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -19396,27 +19155,30 @@

      Static methods

      expected_exception: Exception class expected to be raised. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertRaisesRegex is used as a context manager.

      + when assertRaisesRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertRaisesRegex(self, expected_exception, expected_regex,
      -                      *args, **kwargs):
      +                      callable_obj=None, *args, **kwargs):
           """Asserts that the message in a raised exception matches a regex.
           Args:
               expected_exception: Exception class expected to be raised.
               expected_regex: Regex (re pattern object or string) expected
                       to be found in error message.
      -        args: Function to be called and extra positional args.
      -        kwargs: Extra kwargs.
      +        callable_obj: Function to be called.
               msg: Optional message used in case of failure. Can only be used
                       when assertRaisesRegex is used as a context manager.
      +        args: Extra args.
      +        kwargs: Extra kwargs.
           """
      -    context = _AssertRaisesContext(expected_exception, self, expected_regex)
      -    return context.handle('assertRaisesRegex', args, kwargs)
      +    context = _AssertRaisesContext(expected_exception, self, callable_obj,
      +                                   expected_regex)
      +    return context.handle('assertRaisesRegex', callable_obj, args, kwargs)
       
      @@ -19467,10 +19229,8 @@

      Static methods

      assert expected_regex, "expected_regex must not be empty." expected_regex = re.compile(expected_regex) if not expected_regex.search(text): - standardMsg = "Regex didn't match: %r not found in %r" % ( - expected_regex.pattern, text) - # _formatMessage ensures the longMessage option is respected - msg = self._formatMessage(msg, standardMsg) + msg = msg or "Regex didn't match" + msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text) raise self.failureException(msg)
      @@ -19745,19 +19505,19 @@

      Static methods

      -

      def assertWarns(

      self, expected_warning, *args, **kwargs)

      +

      def assertWarns(

      self, expected_warning, callable_obj=None, *args, **kwargs)

      Fail unless a warning of class warnClass is triggered -by the callable when invoked with specified positional and -keyword arguments. If a different type of warning is +by callable_obj when invoked with arguments args and keyword +arguments kwargs. If a different type of warning is triggered, it will not be handled: depending on the other warning filtering rules in effect, it might be silenced, printed out, or raised as an exception.

      -

      If called with the callable and arguments omitted, will return a +

      If called with callable_obj omitted or None, will return a context object used like this::

       with self.assertWarns(SomeWarning):
            do_something()
      @@ -19779,14 +19539,14 @@ 

      Static methods

      -
      def assertWarns(self, expected_warning, *args, **kwargs):
      +    
      def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
           """Fail unless a warning of class warnClass is triggered
      -       by the callable when invoked with specified positional and
      -       keyword arguments.  If a different type of warning is
      +       by callable_obj when invoked with arguments args and keyword
      +       arguments kwargs.  If a different type of warning is
              triggered, it will not be handled: depending on the other
              warning filtering rules in effect, it might be silenced, printed
              out, or raised as an exception.
      -       If called with the callable and arguments omitted, will return a
      +       If called with callable_obj omitted or None, will return a
              context object used like this::
                   with self.assertWarns(SomeWarning):
                       do_something()
      @@ -19802,8 +19562,8 @@ 

      Static methods

      the_warning = cm.warning self.assertEqual(the_warning.some_attribute, 147) """ - context = _AssertWarnsContext(expected_warning, self) - return context.handle('assertWarns', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj) + return context.handle('assertWarns', callable_obj, args, kwargs)
      @@ -19814,7 +19574,7 @@

      Static methods

      -

      def assertWarnsRegex(

      self, expected_warning, expected_regex, *args, **kwargs)

      +

      def assertWarnsRegex(

      self, expected_warning, expected_regex, callable_obj=None, *args, **kwargs)

      @@ -19828,15 +19588,16 @@

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used - when assertWarnsRegex is used as a context manager.

      + when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs.

      def assertWarnsRegex(self, expected_warning, expected_regex,
      -                     *args, **kwargs):
      +                     callable_obj=None, *args, **kwargs):
           """Asserts that the message in a triggered warning matches a regexp.
           Basic functioning is similar to assertWarns() with the addition
           that only warnings whose messages also match the regular expression
      @@ -19845,13 +19606,15 @@ 

      Static methods

      expected_warning: Warning class expected to be triggered. expected_regex: Regex (re pattern object or string) expected to be found in error message. - args: Function to be called and extra positional args. - kwargs: Extra kwargs. + callable_obj: Function to be called. msg: Optional message used in case of failure. Can only be used when assertWarnsRegex is used as a context manager. + args: Extra args. + kwargs: Extra kwargs. """ - context = _AssertWarnsContext(expected_warning, self, expected_regex) - return context.handle('assertWarnsRegex', args, kwargs) + context = _AssertWarnsContext(expected_warning, self, callable_obj, + expected_regex) + return context.handle('assertWarnsRegex', callable_obj, args, kwargs)
      @@ -20446,7 +20209,6 @@

      Static methods

      -

      Hook method for deconstructing the test fixture after testing it.

      diff --git a/docs/gitnet/helpers.m.html b/docs/gitnet/helpers.m.html index 8bcf75f..6d9e0e4 100644 --- a/docs/gitnet/helpers.m.html +++ b/docs/gitnet/helpers.m.html @@ -1052,6 +1052,9 @@
    • filter_since
    • filter_sincex
    • list_to_scd
    • +
    • make_domain
    • +
    • make_utc_date
    • +
    • make_utc_datetime
    • most_common
    • most_occurrences
    • net_edges_changes
    • @@ -1094,11 +1097,11 @@

      gitnet.helpers module

      # If not, see <http://www.gnu.org/licenses/>. # ********************************************************************************************* -import datetime as dt import re +import warnings +import datetime as dt from gitnet.exceptions import InputError - # Working with Git Log date strings def datetime_git(s): """ @@ -1136,7 +1139,6 @@

      gitnet.helpers module

      "(e.g. 'Mon Apr 18 00:59:02 2016 -0400') or a datetime object.") return ref_date - # Filtering functions. def filter_since(s, match): """ @@ -1287,8 +1289,30 @@

      gitnet.helpers module

      except TypeError: return False +def list_to_scd(lst): + """ + Produces a string which joins the items of the list by semicolons. Non-string items are converted to strings + prior to joining. + + **Parameters** + + >*lst* : `list` + >> A list of items which are either strings or objects which can be converted to strings using `str()` + + **Return** `str` + > A String which includes each item within `lst`, separated by semicolons. + """ + new_lst = [] + for i in lst: + if not isinstance(i, str): + new_lst.append(str(i)) + else: + new_lst.append(i) + + string = ';'.join(new_lst) + + return string -# Working with lists. def most_common(lst, n=1): """ Produces a list containing the n most common entries (occurring more than once) in a list. If the nth most common @@ -1337,7 +1361,6 @@

      gitnet.helpers module

      return sorted(ret_list, reverse=True) - def most_occurrences(lst): """ Produces the number of times the most common value appears. @@ -1365,32 +1388,6 @@

      gitnet.helpers module

      m_common.append(i) return max - -def list_to_scd(lst): - """ - Produces a string which joins the items of the list by semicolons. Non-string items are converted to strings - prior to joining. - - **Parameters** - - >*lst* : `list` - >> A list of items which are either strings or objects which can be converted to strings using `str()` - - **Return** `str` - > A String which includes each item within `lst`, separated by semicolons. - """ - new_lst = [] - for i in lst: - if not isinstance(i, str): - new_lst.append(str(i)) - else: - new_lst.append(i) - - string = ';'.join(new_lst) - - return string - - # Network Edge Generator Functions def net_edges_simple(v1, v2, record, keep): """ @@ -1466,7 +1463,6 @@

      gitnet.helpers module

      properties["weight"] = int(weight) return (v1, v2, properties) - # Network Attribute Helper Functions def node_colours(d): """ @@ -1503,6 +1499,83 @@

      gitnet.helpers module

      return "lightgrey" else: return "lightgrey" + +# Helpers for making UTC time strings from git time strings. + +def make_utc_date(dict): + """ + Takes an attribute dictionary. If "date" present, returns "YYYY-MM-DD" in Coordinated Universal Time. + Otherwise, returns None. "date" must be a git-formatted string, e.g. 'Mon Apr 18 00:59:02 2016 -0400'. + + **Parameters**: + + > *dict* : `dict` + + >> An attribute dictionary. + + **Return** `string` or `none` + """ + if "date" in dict: + git_dt = datetime_git(dict["date"]).astimezone(dt.timezone(dt.timedelta(0))) + return git_dt.strftime("%Y-%m-%d") + else: + return None + +def make_utc_datetime(dict): + """ + Takes an attribute dictionary. If "date" present, returns "YYYY-MM-DD HH:MM:SS" in + Coordinated Universal Time. Otherwise, returns None. "date" must be a git-formatted string, + e.g. 'Mon Apr 18 00:59:02 2016 -0400'. + + **Parameters**: + + > *dict* : `dict` + + >> An attribute dictionary. + + **Return** `string` or `none` + """ + if "date" in dict: + git_dt = datetime_git(dict["date"]).astimezone(dt.timezone(dt.timedelta(0))) + return git_dt.strftime("%Y-%m-%d %H:%M:%S") + else: + return None + +def make_domain(dict): + """ + Takes an attribute dictionary. If "email" present, returns its domain. Otherwise, returns None. + + **Parameters**: + + > *dict* : `dict` + + >> An attribute dictionary. + + **Return** `string` or `none` + """ + # Check if email is in the data dictionary. + if "email" in dict: + try: + # Handling invalid emails. Check if the string is valid format with regex. + if dict["email"] == "" or dict["email"] == None: + return None + email_re = re.compile(".+@.+\..+") + if not re.match(email_re,dict["email"]): + return None + # Handling valid emails by stripping away non-domain characters. + domain = dict["email"].split("@")[1] + go = True + while go: + if domain[-1] == ".": + go = False + domain = domain[:-1] + return domain + except: + return None + warnings.warn("Domain generator failed for: [{}]. Assigned None value.".format(dict["email"])) + # If missing, produce none. + else: + return None
      @@ -2051,6 +2124,165 @@

      Functions

      +
      +
      +

      def make_domain(

      dict)

      +
      + + + + +

      Takes an attribute dictionary. If "email" present, returns its domain. Otherwise, returns None.

      +

      Parameters:

      +
      +

      dict : dict

      +
      +

      An attribute dictionary.

      +
      +
      +

      Return string or none

      +
      + +
      +
      def make_domain(dict):
      +    """
      +    Takes an attribute dictionary. If "email" present, returns its domain. Otherwise, returns None.
      +
      +    **Parameters**:
      +
      +    > *dict* : `dict`
      +
      +    >> An attribute dictionary.
      +
      +    **Return** `string` or `none`
      +    """
      +    # Check if email is in the data dictionary.
      +    if "email" in dict:
      +        try:
      +            # Handling invalid emails. Check if the string is valid format with regex.
      +            if dict["email"] == "" or dict["email"] == None:
      +                return None
      +            email_re = re.compile(".+@.+\..+")
      +            if not re.match(email_re,dict["email"]):
      +                return None
      +            # Handling valid emails by stripping away non-domain characters.
      +            domain = dict["email"].split("@")[1]
      +            go = True
      +            while go:
      +                if domain[-1] == ".":
      +                    go = False
      +                domain = domain[:-1]
      +            return domain
      +        except:
      +            return None
      +            warnings.warn("Domain generator failed for: [{}]. Assigned None value.".format(dict["email"]))
      +    # If missing, produce none.
      +    else:
      +        return None
      +
      + +
      +
      + +
      + + +
      +
      +

      def make_utc_date(

      dict)

      +
      + + + + +

      Takes an attribute dictionary. If "date" present, returns "YYYY-MM-DD" in Coordinated Universal Time. +Otherwise, returns None. "date" must be a git-formatted string, e.g. 'Mon Apr 18 00:59:02 2016 -0400'.

      +

      Parameters:

      +
      +

      dict : dict

      +
      +

      An attribute dictionary.

      +
      +
      +

      Return string or none

      +
      + +
      +
      def make_utc_date(dict):
      +    """
      +    Takes an attribute dictionary. If "date" present, returns "YYYY-MM-DD" in Coordinated Universal Time.
      +    Otherwise, returns None. "date" must be a git-formatted string, e.g. 'Mon Apr 18 00:59:02 2016 -0400'.
      +
      +    **Parameters**:
      +
      +    > *dict* : `dict`
      +
      +    >> An attribute dictionary.
      +
      +    **Return** `string` or `none`
      +    """
      +    if "date" in dict:
      +        git_dt = datetime_git(dict["date"]).astimezone(dt.timezone(dt.timedelta(0)))
      +        return git_dt.strftime("%Y-%m-%d")
      +    else:
      +        return None
      +
      + +
      +
      + +
      + + +
      +
      +

      def make_utc_datetime(

      dict)

      +
      + + + + +

      Takes an attribute dictionary. If "date" present, returns "YYYY-MM-DD HH:MM:SS" in +Coordinated Universal Time. Otherwise, returns None. "date" must be a git-formatted string, +e.g. 'Mon Apr 18 00:59:02 2016 -0400'.

      +

      Parameters:

      +
      +

      dict : dict

      +
      +

      An attribute dictionary.

      +
      +
      +

      Return string or none

      +
      + +
      +
      def make_utc_datetime(dict):
      +    """
      +    Takes an attribute dictionary. If "date" present, returns "YYYY-MM-DD HH:MM:SS" in
      +    Coordinated Universal Time. Otherwise, returns None. "date" must be a git-formatted string,
      +    e.g. 'Mon Apr 18 00:59:02 2016 -0400'.
      +
      +    **Parameters**:
      +
      +    > *dict* : `dict`
      +
      +    >> An attribute dictionary.
      +
      +    **Return** `string` or `none`
      +    """
      +    if "date" in dict:
      +        git_dt = datetime_git(dict["date"]).astimezone(dt.timezone(dt.timedelta(0)))
      +        return git_dt.strftime("%Y-%m-%d %H:%M:%S")
      +    else:
      +        return None
      +
      + +
      +
      + +
      + +

      def most_common(

      lst, n=1)

      diff --git a/docs/gitnet/log.m.html b/docs/gitnet/log.m.html index 46c0679..c689809 100644 --- a/docs/gitnet/log.m.html +++ b/docs/gitnet/log.m.html @@ -1048,6 +1048,8 @@
      • __init__
      • +
      • add_attribute
      • +
      • annotate
      • attributes
      • author_email_list
      • browse
      • @@ -1059,6 +1061,7 @@
      • generate_network
      • generate_nodes
      • get_tags
      • +
      • mutate_attribute
      • replace_val
      • tsv
      • vector
      • @@ -1102,10 +1105,11 @@

        gitnet.log module

        # If not, see <http://www.gnu.org/licenses/>. # ********************************************************************************************* +import os +import copy +import warnings import pandas as pd import datetime as dt -import warnings -import copy import subprocess as sub from gitnet.multigraph import MultiGraphPlus from gitnet.helpers import datetime_git, filter_before, filter_beforex, filter_since, filter_sincex, \ @@ -1158,7 +1162,8 @@

        gitnet.log module

        self.path = path self.key_type = key_type self.filters = filters - # This must be updated as tags/subclasses are added. Ideally, this would be housed within each subclass. + # Annotate and tags must be updated as tags/subclasses are added. + self.annotate() self.tags = self.get_tags() def __iter__(self): @@ -1175,6 +1180,13 @@

        gitnet.log module

        """ return self.collection[item] + def __len__(self): + """ + The number of records in `self.collection`. + + """ + return len(self.collection) + def __str__(self): """ Basic summary of the `Log`. For a more detailed report (which analyzes record contents) use the `describe` method. @@ -1187,24 +1199,11 @@

        gitnet.log module

        return "Log containing {} records from {} created at {}."\ .format(len(self.collection), self.source, self.timestamp) - def __len__(self): + def annotate(self): """ - The number of records in `self.collection`. - + A method that automatically runs after initialization. Behaviours only defined for Log subclasses. """ - return len(self.collection) - - def get_tags(self): - """ - For the base `Log` class, tags defaults to an empty list. `Log` subclasses have alternate `get_tags` methods, which - specify the expected data points in their core data sets, and give a preferred order for displaying the data. - - **Return** : `list` - - > An empty list of tags. - - """ - return [] + pass def attributes(self): """ @@ -1235,43 +1234,49 @@

        gitnet.log module

        attr_list = attr_list + sorted(list(attr)) return attr_list - def describe(self): + def add_attribute(self,name,helper): """ - A method which provides a description of the contents of the `Log`. More detailed descriptions are implemented - for individual subclasses. + Creates a new record attribute. - """ - des_basic = "{}\n{}".format(self, self.path) - des_fstart = "" - des_filters = "" + **Parameters** : - if len(self.filters) != 0: - des_fstart = "\nFilters:" - for f in self.filters: - des_filters = "\t{}".format(f) + > *name* : `string` - description = des_basic + des_fstart + des_filters - print(description) - return description + >> The name of the new attribute. - def browse(self): + > *helper* : `None` + + >> A helper function, which takes an attribute dict and produces the new attribute. + + **Return** : + + > A new Log object, identical to self but with the desired attribute. + """ + self_copy = copy.deepcopy(self) + for n in self_copy: + self_copy[n][name] = helper(self_copy[n]) + return self_copy + + def mutate_attribute(self,name,helper): """ - Interactively prints the contents of the Log collection, one record at a time. + Creates a new record attribute, mutating the original log. - **Return** : `None` + **Parameters** : + + > *name* : `string` + + >> The name of the new attribute. + > *helper* : `None` + + >> A helper function, which takes an attribute dict and produces the new attribute. + + **Return** : + + > None """ - for key in self.collection.keys(): - print("----- {} -----".format(key)) - for rkey in self.collection[key].keys(): - print("--- {} ---".format(rkey)) - if type(self.collection[key][rkey]) in [str, int, bool, float]: - print(self.collection[key][rkey]) - elif type(self.collection[key][rkey]) == list: - for s in self.collection[key][rkey]: - print(s) - if input("\nAnother? [press enter to continue, or press q to quit]\n") == "q": - break + for n in self: + self[n][name] = helper(self[n]) def author_email_list(self): """ @@ -1300,6 +1305,44 @@

        gitnet.log module

        print(authors_emails) return authors_emails + def browse(self): + """ + Interactively prints the contents of the Log collection, one record at a time. + + **Return** : `None` + + """ + for key in self.collection.keys(): + print("----- {} -----".format(key)) + for rkey in self.collection[key].keys(): + print("--- {} ---".format(rkey)) + if type(self.collection[key][rkey]) in [str, int, bool, float]: + print(self.collection[key][rkey]) + elif type(self.collection[key][rkey]) == list: + for s in self.collection[key][rkey]: + print(s) + if input("\nAnother? [press enter to continue, or press q to quit]\n") == "q": + break + + def describe(self): + """ + A method which provides a description of the contents of the `Log`. More detailed descriptions are implemented + for individual subclasses. + + """ + des_basic = "{}\n{}".format(self, self.path) + des_fstart = "" + des_filters = "" + + if len(self.filters) != 0: + des_fstart = "\nFilters:" + for f in self.filters: + des_filters = "\t{}".format(f) + + description = des_basic + des_fstart + des_filters + print(description) + return description + def detect_dup_emails(self): """ Finds emails which are associated with multiple authors. This list should be a good indicator of authors which @@ -1341,6 +1384,17 @@

        gitnet.log module

        return duplicate_dict + def df(self): + """ + Converts the `Log` to a Pandas dataframe. Recommended method for analyzing attribute data in Python. + + **Return** : `dataframe` + + > Returns a `pandas dataframe` object. Rows are commits by short-hash. Columns are commit attributes. + """ + retval = pd.DataFrame.from_dict(self.collection, orient="index")[self.attributes()] + return retval + def filter(self, tag, fun, match, negate=False, helper=None, summary=None): """ A method which creates a new `Log`, containing only records which match certain criteria. @@ -1477,7 +1531,62 @@

        gitnet.log module

        del new_log.collection[record] return new_log - def tsv(self, ignore=[], fname=None, empty_cols=False): + def get_tags(self): + """ + For the base `Log` class, tags defaults to an empty list. `Log` subclasses have alternate `get_tags` methods, which + specify the expected data points in their core data sets, and give a preferred order for displaying the data. + + **Return** : `list` + + > An empty list of tags. + + """ + return [] + + def replace_val(self, tag, cur_val, new_val): + """ + Searches for user specified values in a specific tag in the `Log` and replaces them with a new value. + This method is particularly useful for combining duplicate names for the same author. + + **Parameters** : + + > *tag* : `string` + + >> The record tag string whose values will be checked (and replaced when appropriate). + + > *cur_val* : `string` + + >> This is the value that the user wants to replace. + + > *new_val* : `string` + + >> This is the value that the user wants to use in the new `Log`. + + **Return** : `Log` + + > Returns a `Log` object with values that have been replaced according to user specifications. + + """ + selfcopy = copy.deepcopy(self) + status = 0 + replaced_vals = 0 + for record in selfcopy.collection: + if tag in selfcopy.collection[record].keys(): + if selfcopy[record][tag] == cur_val: + selfcopy[record][tag] = new_val + status = 2 + replaced_vals = replaced_vals + 1 + elif cur_val != selfcopy.collection[record][tag] and replaced_vals == 0: + status = 1 + if status == 0: + warnings.warn("Failed. The tag requested does not appear in this collection.") + elif status == 1: + warnings.warn("Failed. The value requested does not appear in any records in this collection.") + elif status == 2: + print("Success. You have replaced the " + tag + " value: " + str(cur_val) + " " + str(replaced_vals) + " times.") + return selfcopy + + def tsv(self, fname, ignore=[], empty_cols=False): """ Converts the `Log` to a tab-delimited string (using a tab-delimted format is preferrable to CSV since this option does not change the content strings by removing commas). @@ -1574,20 +1683,10 @@

        gitnet.log module

        warnings.warn("Non-string input forced to string {} time(s).".format(num_forced)) if fname is not None: f.close() - out = "Data written to {}".format(fname) + out = "Data written to {} in {}".format(fname, os.getcwd()) + print(out) return out - def df(self): - """ - Converts the `Log` to a Pandas dataframe. Recommended method for analyzing attribute data in Python. - - **Return** : `dataframe` - - > Returns a `pandas dataframe` object. Rows are commits by short-hash. Columns are commit attributes. - """ - retval = pd.DataFrame.from_dict(self.collection, orient="index")[self.attributes()] - return retval - def vector(self, tag): """ Returns a list containing all of the (keyless) values of a certain tag in the Log collection. @@ -1614,48 +1713,7 @@

        gitnet.log module

        v.append(value) return v - def replace_val(self, tag, cur_val, new_val): - """ - Searches for user specified values in a specific tag in the `Log` and replaces them with a new value. - This method is particularly useful for combining duplicate names for the same author. - - **Parameters** : - - > *tag* : `string` - - >> The record tag string whose values will be checked (and replaced when appropriate). - - > *cur_val* : `string` - - >> This is the value that the user wants to replace. - - > *new_val* : `string` - - >> This is the value that the user wants to use in the new `Log`. - - **Return** : `Log` - - > Returns a `Log` object with values that have been replaced according to user specifications. - - """ - selfcopy = copy.deepcopy(self) - status = 0 - replaced_vals = 0 - for record in selfcopy.collection: - if tag in selfcopy.collection[record].keys(): - if selfcopy[record][tag] == cur_val: - selfcopy[record][tag] = new_val - status = 2 - replaced_vals = replaced_vals + 1 - elif cur_val != selfcopy.collection[record][tag] and replaced_vals == 0: - status = 1 - if status == 0: - warnings.warn("The tag requested does not appear in this collection.") - elif status == 1: - warnings.warn("The value requested does not appear in any records in this collection.") - elif status == 2: - print("Success. You have replaced the " + tag + " value: " + str(cur_val) + " " + str(replaced_vals) + " times.") - return selfcopy +# Network Generation and node and edge writing features, follow a second alpha-ordering. def generate_edges(self, mode1, mode2, helper=net_edges_simple, edge_attributes=[]): """ @@ -1710,107 +1768,7 @@

        gitnet.log module

        for item2 in m2: yield helper(item1, item2, cur, edge_attributes) - def generate_nodes(self, mode1, mode2, keep_atom1=[], keep_vector1=[], keep_atom2=[], keep_vector2=[]): - """ - Generates the bipartite nodes present in the Log object. - - **Parameters** : - - > *mode1* : `string` - - >> The tag string for the first mode type. - - > *mode2* : `string` - - >> The tag string for the second mode type. - - > *keep_atom1* : `list` - - >> Atomic variables for mode1 nodes, recorded when a new node is added to the dictionary. - - > *keep_vector1* : list - - >> Variables for mode1 nodes, for which a new datapoint is recorded for every recurrence. - - > *keep_atom2* : `list` - - >> Atomic variables for mode2 nodes, recorded when a new node is added to the dictionary. - - > *keep_vector2* : `list` - - >> Variables for mode2 nodes, for which a new datapoint is recorded for every recurrence. - - **Return** : - - > A list of tuples, i.e. ("node_id", {attribute_dictionary}). - - *By default, each node should have a record in the following format* : - - > ("id_value", {"id": "id_value", "type": mode, "records": [rkey1, rkey2, ..., rkeyn}) - - > With optional variables kept (i.e. keep_atom_1 etc. are not empty) format is as follows: - - > `("id_value" : {"id": "id_value", "type": mode, "records": [rkey1, rkey2, ..., rkeyn},` - > `atom_tag_1: "atom_value_1", ..., atom_tag_n: "atom_value_n",` - > `vector_tag_1: [value_1_1, ..., value_1_m], ..., vector_tag_n: [value_n_1, ..., value_n_m])` - - """ - nodes = {} - for record in self.collection: - cur = self.collection[record] - if mode1 in cur.keys() and mode2 in cur.keys(): - # Set up mode one data for this record - m1 = cur[mode1] - if type(m1) not in [list, dict, set]: - m1 = [m1] - # Set up mode one data for this record - m2 = cur[mode2] - if type(m2) not in [list, dict, set]: - m2 = [m2] - # Yield node attributes - for item1 in m1: - - if item1 in nodes.keys(): - nodes[item1]["records"].append(record) - for tag in keep_vector1: - if tag in cur.keys(): - if tag not in nodes[item1].keys(): - nodes[item1][tag] = [cur[tag]] - elif tag in cur.keys(): - nodes[item1][tag].append(cur[tag]) - else: - nodes[item1] = {"id": item1, "type": mode1, "records": [record]} - for tag in keep_atom1: - if tag in cur.keys(): - nodes[item1][tag] = cur[tag] - for tag in keep_vector1: - if tag in cur.keys(): - nodes[item1][tag] = [cur[tag]] - for item2 in m2: - if item2 in nodes.keys(): - nodes[item2]["records"].append(record) - for tag in keep_vector2: - if tag in cur.keys(): - if tag not in nodes[item2].keys(): - nodes[item2][tag] = [cur[tag]] - elif tag in cur.keys(): - nodes[item2][tag].append(cur[tag]) - else: - nodes[item2] = {"id": item2, "type": mode2, "records": [record]} - for tag in keep_atom2: - if tag in cur.keys(): - nodes[item2][tag] = cur[tag] - for tag in keep_vector2: - if tag in cur.keys(): - nodes[item2][tag] = [cur[tag]] - if len(nodes) is 0: - warnings.warn("Dictionary of node attributes is empty. Check that mode1 and mode2 names are valid tags.") - node_tuple_list = [] - for n in nodes: - node_tuple_list.append((n,nodes[n])) - return node_tuple_list - - def generate_network(self, mode1, mode2, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[], + def generate_network(self, mode1, mode2, colours=None, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[], mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[]): """ An abstract network generator. For networks that contain authors, any authors that made @@ -1826,6 +1784,14 @@

        gitnet.log module

        >> The tag string for the second mode type. + > *colours* : `string` + + >> The string that specifies the colour preset desired by the user. + >> *Simple* : Returns a graph in which each mode is a different colour (red and white). Attention to the order of modes is required, as there is no table. + >> *Complex* : Returns a graph in which each mode is a different colour, and if `files` is one of the modes, popular file types will be a different colour. + >> Otherwise, simply do not include the colour argument. The defualt colour is light grey for all nodes. + >> Enabling colours will also add the colours column to the node data, which will allow importing into other software. See the walkthrough and R tutorial for the example. + > *edge_helper* : `None` >> The helper function used to compute an edge. @@ -1858,11 +1824,11 @@

        gitnet.log module

        Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). @@ -1883,8 +1849,132 @@

        gitnet.log module

        edges = self.generate_edges(mode1, mode2, helper=edge_helper, edge_attributes=edge_attributes) for edge in edges: graph.add_edges_from([(edge[0], edge[1], edge[2])]) + if colours != None: + if colours == 'simple': + for n in graph.nodes(): + if graph.node[n]['type'] == mode1: + graph.node[n]['colour'] = 'oldlace' + if graph.node[n]['type'] == mode2: + graph.node[n]['colour'] = 'lightcoral' + elif colours == 'complex': + for n in graph.nodes(): + if graph.node[n]['type'] == 'author': + graph.node[n]['colour'] = 'oldlace' + elif ".py" in graph.node[n]['id']: + graph.node[n]['colour'] = 'springgreen' + elif ".cc" in graph.node[n]['id']: + graph.node[n]['colour'] = 'seagreen' + elif ".md" in graph.node[n]['id']: + graph.node[n]['colour'] = 'orange' + elif ".sh" in graph.node[n]['id']: + graph.node[n]["colour"] = "slateblue" + elif ".html" in graph.node[n]["id"]: + graph.node[n]["colour"] = "plum" + else: + graph.node[n]['colour'] = 'lightgrey' + print('Created a MultiGraphPlus network object with {} nodes and {} edges.'.format(graph.number_of_nodes(), graph.number_of_edges())) return graph + def generate_nodes(self, mode1, mode2, keep_atom1=[], keep_vector1=[], keep_atom2=[], keep_vector2=[]): + """ + Generates the bipartite nodes present in the Log object. + + **Parameters** : + + > *mode1* : `string` + + >> The tag string for the first mode type. + + > *mode2* : `string` + + >> The tag string for the second mode type. + + > *keep_atom1* : `list` + + >> Atomic variables for mode1 nodes, recorded when a new node is added to the dictionary. + + > *keep_vector1* : list + + >> Variables for mode1 nodes, for which a new datapoint is recorded for every recurrence. + + > *keep_atom2* : `list` + + >> Atomic variables for mode2 nodes, recorded when a new node is added to the dictionary. + + > *keep_vector2* : `list` + + >> Variables for mode2 nodes, for which a new datapoint is recorded for every recurrence. + + **Return** : + + > A list of tuples, i.e. ("node_id", {attribute_dictionary}). + + *By default, each node should have a record in the following format* : + + > ("id_value", {"id": "id_value", "type": mode, "records": [rkey1, rkey2, ..., rkeyn}) + + > With optional variables kept (i.e. keep_atom_1 etc. are not empty) format is as follows: + + > `("id_value" : {"id": "id_value", "type": mode, "records": [rkey1, rkey2, ..., rkeyn},` + > `atom_tag_1: "atom_value_1", ..., atom_tag_n: "atom_value_n",` + > `vector_tag_1: [value_1_1, ..., value_1_m], ..., vector_tag_n: [value_n_1, ..., value_n_m])` + + """ + nodes = {} + for record in self.collection: + cur = self.collection[record] + if mode1 in cur.keys() and mode2 in cur.keys(): + # Set up mode one data for this record + m1 = cur[mode1] + if type(m1) not in [list, dict, set]: + m1 = [m1] + # Set up mode one data for this record + m2 = cur[mode2] + if type(m2) not in [list, dict, set]: + m2 = [m2] + # Yield node attributes + for item1 in m1: + + if item1 in nodes.keys(): + nodes[item1]["records"].append(record) + for tag in keep_vector1: + if tag in cur.keys(): + if tag not in nodes[item1].keys(): + nodes[item1][tag] = [cur[tag]] + elif tag in cur.keys(): + nodes[item1][tag].append(cur[tag]) + else: + nodes[item1] = {"id": item1, "type": mode1, "records": [record]} + for tag in keep_atom1: + if tag in cur.keys(): + nodes[item1][tag] = cur[tag] + for tag in keep_vector1: + if tag in cur.keys(): + nodes[item1][tag] = [cur[tag]] + for item2 in m2: + if item2 in nodes.keys(): + nodes[item2]["records"].append(record) + for tag in keep_vector2: + if tag in cur.keys(): + if tag not in nodes[item2].keys(): + nodes[item2][tag] = [cur[tag]] + elif tag in cur.keys(): + nodes[item2][tag].append(cur[tag]) + else: + nodes[item2] = {"id": item2, "type": mode2, "records": [record]} + for tag in keep_atom2: + if tag in cur.keys(): + nodes[item2][tag] = cur[tag] + for tag in keep_vector2: + if tag in cur.keys(): + nodes[item2][tag] = [cur[tag]] + if len(nodes) is 0: + warnings.warn("Dictionary of node attributes is empty. Check that mode1 and mode2 names are valid tags.") + node_tuple_list = [] + for n in nodes: + node_tuple_list.append((n,nodes[n])) + return node_tuple_list + def write_edges(self, fname, mode1, mode2, helper=net_edges_simple, edge_attribute=['weight', 'date']): """ Writes an edge list with attributes. @@ -1917,11 +2007,11 @@

        gitnet.log module

        Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). @@ -1957,7 +2047,7 @@

        gitnet.log module

        f.write("\n") # Close file and print summary. f.close() - print("Wrote edgelist with attributes to {}.".format(fname)) + print("Wrote edgelist with attributes to {} in {}.".format(fname, os.getcwd())) def write_nodes(self, fname, mode1, mode2, keep_atom1=[], keep_vector1=[], keep_atom2=[], keep_vector2=[]): """ @@ -2034,7 +2124,7 @@

        gitnet.log module

        else: f.write("\n") f.close() - print("Wrote node attributes to {}.".format(fname)) + print("Wrote node attributes to {} in {}.".format(fname, os.getcwd()))
      @@ -2101,7 +2191,8 @@

      Classes

      self.path = path self.key_type = key_type self.filters = filters - # This must be updated as tags/subclasses are added. Ideally, this would be housed within each subclass. + # Annotate and tags must be updated as tags/subclasses are added. + self.annotate() self.tags = self.get_tags() def __iter__(self): @@ -2118,6 +2209,13 @@

      Classes

      """ return self.collection[item] + def __len__(self): + """ + The number of records in `self.collection`. + + """ + return len(self.collection) + def __str__(self): """ Basic summary of the `Log`. For a more detailed report (which analyzes record contents) use the `describe` method. @@ -2130,24 +2228,11 @@

      Classes

      return "Log containing {} records from {} created at {}."\ .format(len(self.collection), self.source, self.timestamp) - def __len__(self): - """ - The number of records in `self.collection`. - - """ - return len(self.collection) - - def get_tags(self): + def annotate(self): """ - For the base `Log` class, tags defaults to an empty list. `Log` subclasses have alternate `get_tags` methods, which - specify the expected data points in their core data sets, and give a preferred order for displaying the data. - - **Return** : `list` - - > An empty list of tags. - + A method that automatically runs after initialization. Behaviours only defined for Log subclasses. """ - return [] + pass def attributes(self): """ @@ -2178,43 +2263,49 @@

      Classes

      attr_list = attr_list + sorted(list(attr)) return attr_list - def describe(self): + def add_attribute(self,name,helper): """ - A method which provides a description of the contents of the `Log`. More detailed descriptions are implemented - for individual subclasses. + Creates a new record attribute. - """ - des_basic = "{}\n{}".format(self, self.path) - des_fstart = "" - des_filters = "" + **Parameters** : - if len(self.filters) != 0: - des_fstart = "\nFilters:" - for f in self.filters: - des_filters = "\t{}".format(f) + > *name* : `string` - description = des_basic + des_fstart + des_filters - print(description) - return description + >> The name of the new attribute. - def browse(self): + > *helper* : `None` + + >> A helper function, which takes an attribute dict and produces the new attribute. + + **Return** : + + > A new Log object, identical to self but with the desired attribute. + """ + self_copy = copy.deepcopy(self) + for n in self_copy: + self_copy[n][name] = helper(self_copy[n]) + return self_copy + + def mutate_attribute(self,name,helper): """ - Interactively prints the contents of the Log collection, one record at a time. + Creates a new record attribute, mutating the original log. - **Return** : `None` + **Parameters** : + + > *name* : `string` + + >> The name of the new attribute. + + > *helper* : `None` + + >> A helper function, which takes an attribute dict and produces the new attribute. + + **Return** : + > None """ - for key in self.collection.keys(): - print("----- {} -----".format(key)) - for rkey in self.collection[key].keys(): - print("--- {} ---".format(rkey)) - if type(self.collection[key][rkey]) in [str, int, bool, float]: - print(self.collection[key][rkey]) - elif type(self.collection[key][rkey]) == list: - for s in self.collection[key][rkey]: - print(s) - if input("\nAnother? [press enter to continue, or press q to quit]\n") == "q": - break + for n in self: + self[n][name] = helper(self[n]) def author_email_list(self): """ @@ -2243,6 +2334,44 @@

      Classes

      print(authors_emails) return authors_emails + def browse(self): + """ + Interactively prints the contents of the Log collection, one record at a time. + + **Return** : `None` + + """ + for key in self.collection.keys(): + print("----- {} -----".format(key)) + for rkey in self.collection[key].keys(): + print("--- {} ---".format(rkey)) + if type(self.collection[key][rkey]) in [str, int, bool, float]: + print(self.collection[key][rkey]) + elif type(self.collection[key][rkey]) == list: + for s in self.collection[key][rkey]: + print(s) + if input("\nAnother? [press enter to continue, or press q to quit]\n") == "q": + break + + def describe(self): + """ + A method which provides a description of the contents of the `Log`. More detailed descriptions are implemented + for individual subclasses. + + """ + des_basic = "{}\n{}".format(self, self.path) + des_fstart = "" + des_filters = "" + + if len(self.filters) != 0: + des_fstart = "\nFilters:" + for f in self.filters: + des_filters = "\t{}".format(f) + + description = des_basic + des_fstart + des_filters + print(description) + return description + def detect_dup_emails(self): """ Finds emails which are associated with multiple authors. This list should be a good indicator of authors which @@ -2284,6 +2413,17 @@

      Classes

      return duplicate_dict + def df(self): + """ + Converts the `Log` to a Pandas dataframe. Recommended method for analyzing attribute data in Python. + + **Return** : `dataframe` + + > Returns a `pandas dataframe` object. Rows are commits by short-hash. Columns are commit attributes. + """ + retval = pd.DataFrame.from_dict(self.collection, orient="index")[self.attributes()] + return retval + def filter(self, tag, fun, match, negate=False, helper=None, summary=None): """ A method which creates a new `Log`, containing only records which match certain criteria. @@ -2420,7 +2560,62 @@

      Classes

      del new_log.collection[record] return new_log - def tsv(self, ignore=[], fname=None, empty_cols=False): + def get_tags(self): + """ + For the base `Log` class, tags defaults to an empty list. `Log` subclasses have alternate `get_tags` methods, which + specify the expected data points in their core data sets, and give a preferred order for displaying the data. + + **Return** : `list` + + > An empty list of tags. + + """ + return [] + + def replace_val(self, tag, cur_val, new_val): + """ + Searches for user specified values in a specific tag in the `Log` and replaces them with a new value. + This method is particularly useful for combining duplicate names for the same author. + + **Parameters** : + + > *tag* : `string` + + >> The record tag string whose values will be checked (and replaced when appropriate). + + > *cur_val* : `string` + + >> This is the value that the user wants to replace. + + > *new_val* : `string` + + >> This is the value that the user wants to use in the new `Log`. + + **Return** : `Log` + + > Returns a `Log` object with values that have been replaced according to user specifications. + + """ + selfcopy = copy.deepcopy(self) + status = 0 + replaced_vals = 0 + for record in selfcopy.collection: + if tag in selfcopy.collection[record].keys(): + if selfcopy[record][tag] == cur_val: + selfcopy[record][tag] = new_val + status = 2 + replaced_vals = replaced_vals + 1 + elif cur_val != selfcopy.collection[record][tag] and replaced_vals == 0: + status = 1 + if status == 0: + warnings.warn("Failed. The tag requested does not appear in this collection.") + elif status == 1: + warnings.warn("Failed. The value requested does not appear in any records in this collection.") + elif status == 2: + print("Success. You have replaced the " + tag + " value: " + str(cur_val) + " " + str(replaced_vals) + " times.") + return selfcopy + + def tsv(self, fname, ignore=[], empty_cols=False): """ Converts the `Log` to a tab-delimited string (using a tab-delimted format is preferrable to CSV since this option does not change the content strings by removing commas). @@ -2517,20 +2712,10 @@

      Classes

      warnings.warn("Non-string input forced to string {} time(s).".format(num_forced)) if fname is not None: f.close() - out = "Data written to {}".format(fname) + out = "Data written to {} in {}".format(fname, os.getcwd()) + print(out) return out - def df(self): - """ - Converts the `Log` to a Pandas dataframe. Recommended method for analyzing attribute data in Python. - - **Return** : `dataframe` - - > Returns a `pandas dataframe` object. Rows are commits by short-hash. Columns are commit attributes. - """ - retval = pd.DataFrame.from_dict(self.collection, orient="index")[self.attributes()] - return retval - def vector(self, tag): """ Returns a list containing all of the (keyless) values of a certain tag in the Log collection. @@ -2546,59 +2731,18 @@

      Classes

      > Returns a list of values (usually strings or numbers). """ - v = [] - for record in self.collection: - if tag in self.collection[record].keys(): - value = self.collection[record][tag] - if type(value) is list: - for i in value: - v.append(i) - else: - v.append(value) - return v - - def replace_val(self, tag, cur_val, new_val): - """ - Searches for user specified values in a specific tag in the `Log` and replaces them with a new value. - This method is particularly useful for combining duplicate names for the same author. - - **Parameters** : - - > *tag* : `string` - - >> The record tag string whose values will be checked (and replaced when appropriate). - - > *cur_val* : `string` - - >> This is the value that the user wants to replace. - - > *new_val* : `string` - - >> This is the value that the user wants to use in the new `Log`. - - **Return** : `Log` - - > Returns a `Log` object with values that have been replaced according to user specifications. - - """ - selfcopy = copy.deepcopy(self) - status = 0 - replaced_vals = 0 - for record in selfcopy.collection: - if tag in selfcopy.collection[record].keys(): - if selfcopy[record][tag] == cur_val: - selfcopy[record][tag] = new_val - status = 2 - replaced_vals = replaced_vals + 1 - elif cur_val != selfcopy.collection[record][tag] and replaced_vals == 0: - status = 1 - if status == 0: - warnings.warn("The tag requested does not appear in this collection.") - elif status == 1: - warnings.warn("The value requested does not appear in any records in this collection.") - elif status == 2: - print("Success. You have replaced the " + tag + " value: " + str(cur_val) + " " + str(replaced_vals) + " times.") - return selfcopy + v = [] + for record in self.collection: + if tag in self.collection[record].keys(): + value = self.collection[record][tag] + if type(value) is list: + for i in value: + v.append(i) + else: + v.append(value) + return v + +# Network Generation and node and edge writing features, follow a second alpha-ordering. def generate_edges(self, mode1, mode2, helper=net_edges_simple, edge_attributes=[]): """ @@ -2653,6 +2797,113 @@

      Classes

      for item2 in m2: yield helper(item1, item2, cur, edge_attributes) + def generate_network(self, mode1, mode2, colours=None, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[], + mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[]): + """ + An abstract network generator. For networks that contain authors, any authors that made + pull requests will not be transferred from the log. + + **Parameters** : + + > *mode1* : `string` + + >> The tag string for the first mode type. + + > *mode2* : `string` + + >> The tag string for the second mode type. + + > *colours* : `string` + + >> The string that specifies the colour preset desired by the user. + >> *Simple* : Returns a graph in which each mode is a different colour (red and white). Attention to the order of modes is required, as there is no table. + >> *Complex* : Returns a graph in which each mode is a different colour, and if `files` is one of the modes, popular file types will be a different colour. + >> Otherwise, simply do not include the colour argument. The defualt colour is light grey for all nodes. + >> Enabling colours will also add the colours column to the node data, which will allow importing into other software. See the walkthrough and R tutorial for the example. + + > *edge_helper* : `None` + + >> The helper function used to compute an edge. + + > *edge_attributes* : `list` + + >> The tag names of attributes to be saved for each edge. + + > *mode1_atom_attrs* : `list` + + >> The tag names of attributes to be saved once for each node of mode1. + + > *mode2_atom_attrs* : `list` + + >> The tag names of attributes to be saved repeatedly for each node of mode1. + + > *mode1_vector_attrs* : `list` + + >> The tag names of attributes to be saved once for each node of mode2. + + > *mode2_vector_attrs* : `list` + + >> The tag names of attributes to be saved repeatedly for each node of mode2. + + **Return** + + > A `MultiGraphPlus` object, which inherits from the NetworkX MultiGraph class. + + **Notes** : + + Currently, two edge_helper functions are available in gitnet.gn_helpers: + + > `net_edges_simple` + + >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. + + > `net_edges_changes` + + >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). + + >> Computes edges between authors and files based on the number of lines changed in the + + >> corresponding changes string (for example, the weight is 6 for `README.md | 6 +++---`). + + """ + graph = MultiGraphPlus() + graph.mode1 = mode1 + graph.mode2 = mode2 + # Make the nodes and add them to the MultiGraphPlus + nodes = self.generate_nodes(mode1, mode2, keep_atom1=mode1_atom_attrs, keep_vector1=mode1_vector_attrs, + keep_atom2=mode2_atom_attrs, keep_vector2=mode2_vector_attrs) + for node in nodes: + graph.add_node(node[0], node[1]) + # Make the edges and add them to the MultiGraphPlus + edges = self.generate_edges(mode1, mode2, helper=edge_helper, edge_attributes=edge_attributes) + for edge in edges: + graph.add_edges_from([(edge[0], edge[1], edge[2])]) + if colours != None: + if colours == 'simple': + for n in graph.nodes(): + if graph.node[n]['type'] == mode1: + graph.node[n]['colour'] = 'oldlace' + if graph.node[n]['type'] == mode2: + graph.node[n]['colour'] = 'lightcoral' + elif colours == 'complex': + for n in graph.nodes(): + if graph.node[n]['type'] == 'author': + graph.node[n]['colour'] = 'oldlace' + elif ".py" in graph.node[n]['id']: + graph.node[n]['colour'] = 'springgreen' + elif ".cc" in graph.node[n]['id']: + graph.node[n]['colour'] = 'seagreen' + elif ".md" in graph.node[n]['id']: + graph.node[n]['colour'] = 'orange' + elif ".sh" in graph.node[n]['id']: + graph.node[n]["colour"] = "slateblue" + elif ".html" in graph.node[n]["id"]: + graph.node[n]["colour"] = "plum" + else: + graph.node[n]['colour'] = 'lightgrey' + print('Created a MultiGraphPlus network object with {} nodes and {} edges.'.format(graph.number_of_nodes(), graph.number_of_edges())) + return graph + def generate_nodes(self, mode1, mode2, keep_atom1=[], keep_vector1=[], keep_atom2=[], keep_vector2=[]): """ Generates the bipartite nodes present in the Log object. @@ -2753,81 +3004,6 @@

      Classes

      node_tuple_list.append((n,nodes[n])) return node_tuple_list - def generate_network(self, mode1, mode2, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[], - mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[]): - """ - An abstract network generator. For networks that contain authors, any authors that made - pull requests will not be transferred from the log. - - **Parameters** : - - > *mode1* : `string` - - >> The tag string for the first mode type. - - > *mode2* : `string` - - >> The tag string for the second mode type. - - > *edge_helper* : `None` - - >> The helper function used to compute an edge. - - > *edge_attributes* : `list` - - >> The tag names of attributes to be saved for each edge. - - > *mode1_atom_attrs* : `list` - - >> The tag names of attributes to be saved once for each node of mode1. - - > *mode2_atom_attrs* : `list` - - >> The tag names of attributes to be saved repeatedly for each node of mode1. - - > *mode1_vector_attrs* : `list` - - >> The tag names of attributes to be saved once for each node of mode2. - - > *mode2_vector_attrs* : `list` - - >> The tag names of attributes to be saved repeatedly for each node of mode2. - - **Return** - - > A `MultiGraphPlus` object, which inherits from the NetworkX MultiGraph class. - - **Notes** : - - Currently, two edge_helper functions are available in gitnet.gn_helpers: - - > `simple_edge` - - >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - - > `changes_edge` - - >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). - - >> Computes edges between authors and files based on the number of lines changed in the - - >> corresponding changes string (for example, the weight is 6 for `README.md | 6 +++---`). - - """ - graph = MultiGraphPlus() - graph.mode1 = mode1 - graph.mode2 = mode2 - # Make the nodes and add them to the MultiGraphPlus - nodes = self.generate_nodes(mode1, mode2, keep_atom1=mode1_atom_attrs, keep_vector1=mode1_vector_attrs, - keep_atom2=mode2_atom_attrs, keep_vector2=mode2_vector_attrs) - for node in nodes: - graph.add_node(node[0], node[1]) - # Make the edges and add them to the MultiGraphPlus - edges = self.generate_edges(mode1, mode2, helper=edge_helper, edge_attributes=edge_attributes) - for edge in edges: - graph.add_edges_from([(edge[0], edge[1], edge[2])]) - return graph - def write_edges(self, fname, mode1, mode2, helper=net_edges_simple, edge_attribute=['weight', 'date']): """ Writes an edge list with attributes. @@ -2860,11 +3036,11 @@

      Classes

      Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). @@ -2900,7 +3076,7 @@

      Classes

      f.write("\n") # Close file and print summary. f.close() - print("Wrote edgelist with attributes to {}.".format(fname)) + print("Wrote edgelist with attributes to {} in {}.".format(fname, os.getcwd())) def write_nodes(self, fname, mode1, mode2, keep_atom1=[], keep_vector1=[], keep_atom2=[], keep_vector2=[]): """ @@ -2977,7 +3153,7 @@

      Classes

      else: f.write("\n") f.close() - print("Wrote node attributes to {}.".format(fname)) + print("Wrote node attributes to {} in {}.".format(fname, os.getcwd()))
      @@ -3060,7 +3236,8 @@

      Static methods

      self.path = path self.key_type = key_type self.filters = filters - # This must be updated as tags/subclasses are added. Ideally, this would be housed within each subclass. + # Annotate and tags must be updated as tags/subclasses are added. + self.annotate() self.tags = self.get_tags()
      @@ -3070,6 +3247,81 @@

      Static methods

      +
      +
      +

      def add_attribute(

      self, name, helper)

      +
      + + + + +

      Creates a new record attribute.

      +

      Parameters :

      +
      +

      name : string

      +
      +

      The name of the new attribute.

      +
      +

      helper : None

      +
      +

      A helper function, which takes an attribute dict and produces the new attribute.

      +
      +
      +

      Return :

      +
      +

      A new Log object, identical to self but with the desired attribute.

      +
      +
      + +
      +
      def add_attribute(self,name,helper):
      +    """
      +    Creates a new record attribute.
      +    **Parameters** :
      +    > *name* : `string`
      +    >> The name of the new attribute.
      +    > *helper* : `None`
      +    >> A helper function, which takes an attribute dict and produces the new attribute.
      +    **Return** :
      +    > A new Log object, identical to self but with the desired attribute.
      +    """
      +    self_copy = copy.deepcopy(self)
      +    for n in self_copy:
      +        self_copy[n][name] = helper(self_copy[n])
      +    return self_copy
      +
      + +
      +
      + +
      + + +
      +
      +

      def annotate(

      self)

      +
      + + + + +

      A method that automatically runs after initialization. Behaviours only defined for Log subclasses.

      +
      + +
      +
      def annotate(self):
      +    """
      +    A method that automatically runs after initialization. Behaviours only defined for Log subclasses.
      +    """
      +    pass
      +
      + +
      +
      + +
      + +

      def attributes(

      self)

      @@ -3528,7 +3780,7 @@

      Static methods

      -

      def generate_edges(

      self, mode1, mode2, helper=<function net_edges_simple at 0x112d7a6a8>, edge_attributes=[])

      +

      def generate_edges(

      self, mode1, mode2, helper=<function net_edges_simple at 0x10fdd0a60>, edge_attributes=[])

      @@ -3615,7 +3867,7 @@

      Static methods

      -

      def generate_network(

      self, mode1, mode2, edge_helper=<function net_edges_simple at 0x112d7a6a8>, edge_attributes=[], mode1_atom_attrs=[], mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[])

      +

      def generate_network(

      self, mode1, mode2, colours=None, edge_helper=<function net_edges_simple at 0x10fdd0a60>, edge_attributes=[], mode1_atom_attrs=[], mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[])

      @@ -3633,6 +3885,14 @@

      Static methods

      The tag string for the second mode type.

      +

      colours : string

      +
      +

      The string that specifies the colour preset desired by the user. +Simple : Returns a graph in which each mode is a different colour (red and white). Attention to the order of modes is required, as there is no table. +Complex : Returns a graph in which each mode is a different colour, and if files is one of the modes, popular file types will be a different colour. +Otherwise, simply do not include the colour argument. The defualt colour is light grey for all nodes. +Enabling colours will also add the colours column to the node data, which will allow importing into other software. See the walkthrough and R tutorial for the example.

      +

      edge_helper : None

      The helper function used to compute an edge.

      @@ -3665,11 +3925,11 @@

      Static methods

      Notes :

      Currently, two edge_helper functions are available in gitnet.gn_helpers:

      -

      simple_edge

      +

      net_edges_simple

      Creates an unweighted edge, and saves the attributes specified by edge_attributes.

      -

      changes_edge

      +

      net_edges_changes

      Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog).

      Computes edges between authors and files based on the number of lines changed in the

      @@ -3679,7 +3939,7 @@

      Static methods

      -
      def generate_network(self, mode1, mode2, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[],
      +    
      def generate_network(self, mode1, mode2, colours=None, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[],
                            mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[]):
           """
           An abstract network generator. For networks that contain authors, any authors that made
      @@ -3689,6 +3949,12 @@ 

      Static methods

      >> The tag string for the first mode type. > *mode2* : `string` >> The tag string for the second mode type. + > *colours* : `string` + >> The string that specifies the colour preset desired by the user. + >> *Simple* : Returns a graph in which each mode is a different colour (red and white). Attention to the order of modes is required, as there is no table. + >> *Complex* : Returns a graph in which each mode is a different colour, and if `files` is one of the modes, popular file types will be a different colour. + >> Otherwise, simply do not include the colour argument. The defualt colour is light grey for all nodes. + >> Enabling colours will also add the colours column to the node data, which will allow importing into other software. See the walkthrough and R tutorial for the example. > *edge_helper* : `None` >> The helper function used to compute an edge. > *edge_attributes* : `list` @@ -3705,9 +3971,9 @@

      Static methods

      > A `MultiGraphPlus` object, which inherits from the NetworkX MultiGraph class. **Notes** : Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). >> Computes edges between authors and files based on the number of lines changed in the >> corresponding changes string (for example, the weight is 6 for `README.md | 6 +++---`). @@ -3724,6 +3990,30 @@

      Static methods

      edges = self.generate_edges(mode1, mode2, helper=edge_helper, edge_attributes=edge_attributes) for edge in edges: graph.add_edges_from([(edge[0], edge[1], edge[2])]) + if colours != None: + if colours == 'simple': + for n in graph.nodes(): + if graph.node[n]['type'] == mode1: + graph.node[n]['colour'] = 'oldlace' + if graph.node[n]['type'] == mode2: + graph.node[n]['colour'] = 'lightcoral' + elif colours == 'complex': + for n in graph.nodes(): + if graph.node[n]['type'] == 'author': + graph.node[n]['colour'] = 'oldlace' + elif ".py" in graph.node[n]['id']: + graph.node[n]['colour'] = 'springgreen' + elif ".cc" in graph.node[n]['id']: + graph.node[n]['colour'] = 'seagreen' + elif ".md" in graph.node[n]['id']: + graph.node[n]['colour'] = 'orange' + elif ".sh" in graph.node[n]['id']: + graph.node[n]["colour"] = "slateblue" + elif ".html" in graph.node[n]["id"]: + graph.node[n]["colour"] = "plum" + else: + graph.node[n]['colour'] = 'lightgrey' + print('Created a MultiGraphPlus network object with {} nodes and {} edges.'.format(graph.number_of_nodes(), graph.number_of_edges())) return graph
      @@ -3903,6 +4193,54 @@

      Static methods

      +
      +
      +

      def mutate_attribute(

      self, name, helper)

      +
      + + + + +

      Creates a new record attribute, mutating the original log.

      +

      Parameters :

      +
      +

      name : string

      +
      +

      The name of the new attribute.

      +
      +

      helper : None

      +
      +

      A helper function, which takes an attribute dict and produces the new attribute.

      +
      +
      +

      Return :

      +
      +

      None

      +
      +
      + +
      +
      def mutate_attribute(self,name,helper):
      +    """
      +    Creates a new record attribute, mutating the original log.
      +    **Parameters** :
      +    > *name* : `string`
      +    >> The name of the new attribute.
      +    > *helper* : `None`
      +    >> A helper function, which takes an attribute dict and produces the new attribute.
      +    **Return** :
      +    > None
      +    """
      +    for n in self:
      +        self[n][name] = helper(self[n])
      +
      + +
      +
      + +
      + +

      def replace_val(

      self, tag, cur_val, new_val)

      @@ -3961,9 +4299,9 @@

      Static methods

      elif cur_val != selfcopy.collection[record][tag] and replaced_vals == 0: status = 1 if status == 0: - warnings.warn("The tag requested does not appear in this collection.") + warnings.warn("Failed. The tag requested does not appear in this collection.") elif status == 1: - warnings.warn("The value requested does not appear in any records in this collection.") + warnings.warn("Failed. The value requested does not appear in any records in this collection.") elif status == 2: print("Success. You have replaced the " + tag + " value: " + str(cur_val) + " " + str(replaced_vals) + " times.") return selfcopy @@ -3977,7 +4315,7 @@

      Static methods

      -

      def tsv(

      self, ignore=[], fname=None, empty_cols=False)

      +

      def tsv(

      self, fname, ignore=[], empty_cols=False)

      @@ -4008,7 +4346,7 @@

      Static methods

      -
      def tsv(self, ignore=[], fname=None, empty_cols=False):
      +    
      def tsv(self, fname, ignore=[], empty_cols=False):
           """
           Converts the `Log` to a tab-delimited string (using a tab-delimted format is preferrable to CSV since this option
           does not change the content strings by removing commas).
      @@ -4094,7 +4432,8 @@ 

      Static methods

      warnings.warn("Non-string input forced to string {} time(s).".format(num_forced)) if fname is not None: f.close() - out = "Data written to {}".format(fname) + out = "Data written to {} in {}".format(fname, os.getcwd()) + print(out) return out
      @@ -4156,7 +4495,7 @@

      Static methods

      -

      def write_edges(

      self, fname, mode1, mode2, helper=<function net_edges_simple at 0x112d7a6a8>, edge_attribute=['weight', 'date'])

      +

      def write_edges(

      self, fname, mode1, mode2, helper=<function net_edges_simple at 0x10fdd0a60>, edge_attribute=['weight', 'date'])

      @@ -4190,11 +4529,11 @@

      Static methods

      Notes :

      Currently, two edge_helper functions are available in gitnet.gn_helpers:

      -

      simple_edge

      +

      net_edges_simple

      Creates an unweighted edge, and saves the attributes specified by edge_attributes.

      -

      changes_edge

      +

      net_edges_changes

      Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog).

      Computes edges between authors and files based on the number of lines changed in the

      @@ -4221,9 +4560,9 @@

      Static methods

      **Return** : `None` **Notes** : Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). >> Computes edges between authors and files based on the number of lines changed in the >> corresponding changes string (for example, the weight is 6 for `README.md | 6 +++---`). @@ -4255,7 +4594,7 @@

      Static methods

      f.write("\n") # Close file and print summary. f.close() - print("Wrote edgelist with attributes to {}.".format(fname)) + print("Wrote edgelist with attributes to {} in {}.".format(fname, os.getcwd()))
      @@ -4366,7 +4705,7 @@

      Static methods

      else: f.write("\n") f.close() - print("Wrote node attributes to {}.".format(fname)) + print("Wrote node attributes to {} in {}.".format(fname, os.getcwd()))
      diff --git a/docs/gitnet/multigraph.m.html b/docs/gitnet/multigraph.m.html index b707e0a..a57bd1c 100644 --- a/docs/gitnet/multigraph.m.html +++ b/docs/gitnet/multigraph.m.html @@ -1134,12 +1134,13 @@

      gitnet.multigraph module

      # ********************************************************************************************* import networkx as nx +import matplotlib.pyplot as plt +import numpy as np +import os import warnings +import copy from gitnet.exceptions import MergeError from gitnet.helpers import list_to_scd -import matplotlib.pyplot as plt -import copy -import numpy as np from gitnet.helpers import datetime_git from networkx.drawing.nx_agraph import graphviz_layout from networkx.algorithms import bipartite @@ -1151,146 +1152,207 @@

      gitnet.multigraph module

      mode2 = "" - def write_graphml(self, fname): + def collapse_edges(self, sum_weights=False): """ - Converts a `MultiGraphPlus` object to a graphml file. + Collapses all edges which share nodes into one edge, with a new weight assigned to it. How this weight is + assigned depends on the `sum_weights` parameter. **Parameters** : - > *fname* : + > *sum_weights* : `bool` - >> A string indicating the path or file name to write to. File names which end in `.gz` or `.bz2` will be compressed. + >> An optional boolean parameter. Determines how weights will be assigned to the final edges. + >> If False, the weight will be the number of edges which were collapsed. If True, the weight will be the sum of + >> the weights of collapsed edges. - **Return** : `None` + **Return** : - > This method will have the side effect of creating a file, specified by fpath. - > This method cannot use vector attributes within the graphml file. Instead, vector attributes are converted into - > a semicolon-delimited string. When this occurs, a warning is raised indicating the vector attributes (node - > attributes are preceded by 'n:' while edge attributes are preceded by 'e:'). + > A new MultiGraphPlus object, which has collapsed all duplicate edges, assigned a new weight, and + > stores other edge data in lists. + + **Note** : + + > The default weight of an edge is 1. Thus, if sum_weights is set to True, but an edge does not have a + > weight attribute, this method assumes the weight of the edge is 1. """ + gnew = MultiGraphPlus() + for n1, n2, data in self.edges(data=True): + if gnew.has_edge(n1, n2): + gnew_data = gnew.edge[n1][n2][0] + if 'weight' not in data: + gnew_data['weight'] += 1 + for k in data: + if k in gnew_data: + if k == 'weight': + if sum_weights: + gnew_data[k] += data[k] + else: + gnew_data[k] += 1 + elif isinstance(data[k], list): + gnew_data[k] += data[k] + else: + if isinstance(gnew_data[k], list): + gnew_data[k] += [data[k]] + else: + gnew_data[k] = [gnew_data[k], data[k]] + else: + gnew_data[k] = data[k] + else: + edge_attr = {'weight': 1} + for k in data: + if k == 'weight': + if sum_weights: + edge_attr[k] = data[k] + elif isinstance(data[k], list): + edge_attr[k] = data[k] + else: + edge_attr[k] = data[k] + gnew.add_edge(n1, n2, attr_dict=edge_attr) + return gnew - graph = copy.deepcopy(self) + def describe(self, extra=False): + """ + Provides a summary of graph statistics. Includes basic statistics like the number of nodes, edges, + denstiy, and the average degree for one mode. Prints a string that contains each of the items that make up the summary. + Density is calculated using one of the modes of the original bipartite network graph. - warning = False - warning_set = set([]) - for n in graph.nodes(): - for attr in graph.node[n].keys(): - if isinstance(graph.node[n][attr], list): - warning = True - warning_set = {'n:' + attr} | warning_set - graph.node[n][attr] = list_to_scd(graph.node[n][attr]) + **Parameters** : - for n1, n2, data in graph.edges(data=True): - for k in data: - if isinstance(data[k], list): - warning = True - warning_set = {'e:'+k} | warning_set - data[k] = list_to_scd(data[k]) + > *extra* : `bool` - if warning: - warnings.warn("The provided graph contained the vector attributes: {}. All values of vector attributes have" - " been converted to semicolon-delimited strings. To prevent this, remove vector attributes or" - " convert them to atomic attributes prior to calling .write_graphml" - .format(warning_set)) + >> Runs the low efficiency algorithms, which can be resource-intensive on large networks. + >> Recommended maximum network size for the low efficiency algorithms is around 100 nodes. - nx.write_graphml(graph, fname) + **Returns** : `string` - def write_tnet(self, fname, mode_string="type", weighted=False, time_string="date", node_index_string="tnet_id", - weight_string='weight'): - """ - A function to write an edgelist formatted for the tnet library for network analysis in R. + > Returns the descriptive string that contains information about the `MultiGraphPlus` object. - **Parameters** : + """ + mode1 = self.mode1 + mode2 = self.mode2 + density = bipartite.density(self, bipartite.sets(self)[0]) + edges = self.number_of_edges() + nodes_mode1 = 0 + nodes_mode2 = 0 + for n in self.nodes(): + if self.node[n]['type'] == mode1: + nodes_mode1 += 1 + elif self.node[n]['type'] == mode2: + nodes_mode2 += 1 - > *fname* : `string` + descriptives_nodes = "This is a bipartite network of types '{}' and '{}'.\n " \ + "{} nodes are of the type '{}'.\n " \ + "{} nodes are of the type '{}'.\n".format(str(mode1), str(mode2), str(nodes_mode1), + str(mode1), str(nodes_mode2), str(mode2)) + descriptives_edges = "There are {} edges.\n".format(str(edges)) + descriptives_density = "Density: {}.\n".format(str(density)) + descriptives = descriptives_nodes + descriptives_edges + descriptives_density - >> A string indicating the path or file name to write to. + if extra: + # Note: for each mode of the bipartite graph, degree and betweenness centrality are the same. + # Keeping them both makes it easy to compare them and make sure they are the same. + degree_mode1 = bipartite.degree_centrality(self, bipartite.sets(self)[0]) + degree_mode2 = bipartite.degree_centrality(self, bipartite.sets(self)[1]) + degree_mode1 = list(degree_mode1.values()) + degree_mode2 = list(degree_mode2.values()) + degree_mode1 = np.mean(degree_mode1) + degree_mode2 = np.mean(degree_mode2) + betweenness_mode1 = bipartite.betweenness_centrality(self, bipartite.sets(self)[0]) + betweenness_mode1 = list(betweenness_mode1.values()) + betweenness_mode1 = np.mean(betweenness_mode1) + betweenness_mode2 = bipartite.betweenness_centrality(self, bipartite.sets(self)[1]) + betweenness_mode2 = list(betweenness_mode2.values()) + betweenness_mode2 = np.mean(betweenness_mode2) + g = nx.Graph(self) + projection = bipartite.projected_graph(g, bipartite.sets(g)[0]) + transitivity = nx.transitivity(projection) + descriptives_transitivity = "Transitivity: {}.\n".format(str(transitivity)) + descriptives_degree_centrality = "Mean Degree Centrality for '{}': {}.\n" \ + "Mean Degree Centrality for '{}': {}.\n".format(str(mode1), + str(degree_mode1), + str(mode2), + str(degree_mode2)) + descriptives_btwn_centrality = "Mean Betweenness Centrality for '{}': {}.\n"\ + "Mean Betweenness Centrality for '{}': {}.\n".format(str(mode1), + str(betweenness_mode1), + str(mode2), + str(betweenness_mode2)) + descriptives = descriptives + descriptives_transitivity +\ + descriptives_degree_centrality + descriptives_btwn_centrality + print(descriptives) + return descriptives - > *mode_string* : `string` + def node_merge(self, node1, node2, show_warning=True): + """ + Combines node1 and node2. After merge, node1 will remain, while node2 will be removed. node2's edges will become + node1 edges, while retaining all their edge attributes. Vector attributes of node1 and node2 whose + identifiers match will be combined, retaining all values. Atomic attributes which exist in only one of the + two nodes will be included in the merge node. Finally, if node1 and node2 contain a conflicting atomic + attribute, node1's value will overwrite node2's value. - >> The name string of the mode node attribute. + **Parameters** : - > *weighted* : `bool` + > *node1* : `string` - >> Do the edges have weights? True or false. + >> The identifier for a node. This node's attributes will persist to the merged node. - > *time_string* : `string` + > *node2* : `string` - >> the name string of the date/time node attribute. + >> The identifier for a second node. Any non-conflicting attributes will persist to the merged node. - > *node_index_string* : `int` + > *show_warning* : `bool` - >> Creates a new integer id attribute. + >> A boolean parameter indicating whether overwrite warnings should be displayed. - > *weight_string* : `string` + **Return** : `MultiGraphPlus` - >> The name of the weight node attribute. + > a new multigraphplus object which has merged nodes 1 and 2 together into node1, which will also have gained node2's edges. - **Return** : `None` + """ + merged_graph = copy.deepcopy(self) - *Source* : + # Check: Both node1 and node2 exist in merged_graph + if node1 not in merged_graph.nodes(): + raise MergeError(node1 + " is not a valid node") + if node2 not in merged_graph.nodes(): + raise MergeError(node2 + " is not a valid node") - > Adapted from code written by Reid McIlroy Young for the Metaknowledge python library. + # Check: node1 and node2's types are the same + if 'type' in merged_graph.node[node1] and 'type' in merged_graph.node[node2]: + if merged_graph.node[node1]['type'] != merged_graph.node[node2]['type']: + raise MergeError("node1 and node2's types do not match") - """ - modes = [] - mode1set = set() - for node_index, node in enumerate(self.nodes_iter(data=True), start=1): - try: - nmode = node[1][mode_string] - except KeyError: - # too many modes so will fail - modes = [1, 2, 3] - nmode = 4 - if nmode not in modes: - if len(modes) < 2: - modes.append(nmode) - else: - raise ValueError( - "Too many modes of '{}' found in the network or one of the nodes was missing its mode. " - "There must be exactly 2 modes.".format(mode_string)) - if nmode == modes[0]: - mode1set.add(node[0]) - node[1][node_index_string] = node_index - if len(modes) != 2: - raise ValueError( - "Too few modes of '{}' found in the network. There must be exactly 2 modes.".format(mode_string)) - with open(fname, 'w', encoding='utf-8') as f: - for n1, n2, eDict in self.edges_iter(data=True): - if n1 in mode1set: - if n2 in mode1set: - raise ValueError( - "The nodes '{}' and '{}' have an edge and the same type. " - "The network must be purely 2-mode.".format(n1, n2)) - elif n2 in mode1set: - n1, n2 = n2, n1 - else: - raise ValueError( - "The nodes '{}' and '{}' have an edge and the same type. " - "The network must be purely 2-mode.".format(n1, n2)) + # Moves all edges from node2 to node1 + for e in merged_graph.edges(node2, data=True): + merged_graph.add_edge(node1, e[1], attr_dict=e[2]) + merged_graph.remove_edge(e[0], e[1]) - if time_string is not None and time_string in eDict: - edt = eDict[time_string] - if type(edt) is str: - edt = datetime_git(eDict[time_string]) - e_time_string = edt.strftime("\"%y-%m-%d %H:%M:%S\"") - else: - e_time_string = '' + # Adds node2's attributes to node1. There are three cases for this: + # 1. Vector attributes are joined to create one larger vector + # 2. Non-conflicting Atomic attributes are kept and preserved in the final node + # 3. Conflicting Atomic attributes are not added from node2 (node1 values persist) + node_merge_warn = False + node_merge_warn_list = [] - # Write to file - node1 = self.node[n1][node_index_string] - node2 = self.node[n2][node_index_string] - if time_string is not None: - f.write("{} {} {}".format(e_time_string, node1, node2)) - else: - f.write("{} {}".format(node1, node2)) + for na in merged_graph.node[node2]: + if na not in merged_graph.node[node1]: # Deals with case 2 + merged_graph.node[node1][na] = merged_graph.node[node2][na] + elif isinstance(merged_graph.node[node2][na], list): # Deals with case 1 + merged_graph.node[node1][na] = merged_graph.node[node1][na] + merged_graph.node[node2][na] + elif merged_graph.node[node1][na] != merged_graph.node[node2][na]: + node_merge_warn = True + node_merge_warn_list.append(na) - if weighted: - weight = eDict[weight_string] - f.write(" {}\n".format(weight)) - else: - f.write("\n") + merged_graph.remove_node(node2) # Removes node2 + + if node_merge_warn and show_warning: + print("Note: nodes '{}' and '{}' have the following conflicting atomic attributes: {}. In these cases, " + "'{}' attribute values have been retained, while '{}' values have been ignored. If you would rather " + "retain '{}' attributes, set '{}' to node1 and '{}' to node2." + .format(node1, node2, node_merge_warn_list, node1, node2, node2, node2, node1)) + + return merged_graph def node_attributes(self, name, helper): """ @@ -1370,201 +1432,223 @@

      gitnet.multigraph module

      print("Plotting...") if layout in ["dot", "neato", "fdp", "circo"]: nx.draw(copy_net, - pos=graphviz_layout(copy_net, prog=layout), - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + pos=graphviz_layout(copy_net, prog=layout), + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) if layout == "spring": nx.draw(copy_net, - pos=nx.spring_layout(copy_net, k=k, iterations=iterations), - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + pos=nx.spring_layout(copy_net, k=k, iterations=iterations), + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "circular": nx.draw_circular(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "shell": nx.draw_shell(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "spectral": nx.draw_spectral(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "random": nx.draw_random(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) # Save figure if applicable if fname is not None: plt.savefig(fname, bbox_inches="tight") - print("Wrote file: {}".format(fname)) + print("Wrote file: {} to {}".format(fname, os.getcwd())) - def describe(self, extra=False): + def write_graphml(self, fname): """ - Provides a summary of graph statistics. Includes basic statistics like the number of nodes, edges, - denstiy, and the average degree for one mode. Prints a string that contains each of the items that make up the summary. - Density is calculated using one of the modes of the original bipartite network graph. + Converts a `MultiGraphPlus` object to a graphml file. **Parameters** : - > *extra* : `bool` + > *fname* : - >> Runs the low efficiency algorithms, which can be resource-intensive on large networks. - >> Recommended maximum network size for the low efficiency algorithms is around 100 nodes. + >> A string indicating the path or file name to write to. File names which end in `.gz` or `.bz2` will be compressed. - **Returns** : `string` + **Return** : `None` - > Returns the descriptive string that contains information about the `MultiGraphPlus` object. + > This method will have the side effect of creating a file, specified by fpath. + > This method cannot use vector attributes within the graphml file. Instead, vector attributes are converted into + > a semicolon-delimited string. When this occurs, a warning is raised indicating the vector attributes (node + > attributes are preceded by 'n:' while edge attributes are preceded by 'e:'). """ - mode1 = self.mode1 - mode2 = self.mode2 - density = bipartite.density(self, bipartite.sets(self)[0]) - edges = self.number_of_edges() - nodes_mode1 = 0 - nodes_mode2 = 0 - for n in self.nodes(): - if self.node[n]['type'] == mode1: - nodes_mode1 += 1 - elif self.node[n]['type'] == mode2: - nodes_mode2 += 1 - descriptives_nodes = "This is a bipartite network of types '{}' and '{}'.\n " \ - "{} nodes are of the type '{}'.\n " \ - "{} nodes are of the type '{}'.\n".format(str(mode1), str(mode2), str(nodes_mode1), - str(mode1), str(nodes_mode2), str(mode2)) - descriptives_edges = "There are {} edges.\n".format(str(edges)) - descriptives_density = "Density: {}.\n".format(str(density)) - descriptives = descriptives_nodes + descriptives_edges + descriptives_density + graph = copy.deepcopy(self) - if extra: - # Note: for each mode of the bipartite graph, degree and betweenness centrality are the same. - # Keeping them both makes it easy to compare them and make sure they are the same. - degree_mode1 = bipartite.degree_centrality(self, bipartite.sets(self)[0]) - degree_mode2 = bipartite.degree_centrality(self, bipartite.sets(self)[1]) - degree_mode1 = list(degree_mode1.values()) - degree_mode2 = list(degree_mode2.values()) - degree_mode1 = np.mean(degree_mode1) - degree_mode2 = np.mean(degree_mode2) - betweenness_mode1 = bipartite.betweenness_centrality(self, bipartite.sets(self)[0]) - betweenness_mode1 = list(betweenness_mode1.values()) - betweenness_mode1 = np.mean(betweenness_mode1) - betweenness_mode2 = bipartite.betweenness_centrality(self, bipartite.sets(self)[1]) - betweenness_mode2 = list(betweenness_mode2.values()) - betweenness_mode2 = np.mean(betweenness_mode2) - g = nx.Graph(self) - projection = bipartite.projected_graph(g, bipartite.sets(g)[0]) - transitivity = nx.transitivity(projection) - descriptives_transitivity = "Transitivity: {}.\n".format(str(transitivity)) - descriptives_degree_centrality = "Mean Degree Centrality for '{}': {}.\n" \ - "Mean Degree Centrality for '{}': {}.\n".format(str(mode1), - str(degree_mode1), - str(mode2), - str(degree_mode2)) - descriptives_btwn_centrality = "Mean Betweenness Centrality for '{}': {}.\n"\ - "Mean Betweenness Centrality for '{}': {}.\n".format(str(mode1), - str(betweenness_mode1), - str(mode2), - str(betweenness_mode2)) - descriptives = descriptives + descriptives_transitivity +\ - descriptives_degree_centrality + descriptives_btwn_centrality - print(descriptives) - return descriptives + warning = False + warning_set = set([]) + for n in graph.nodes(): + for attr in graph.node[n].keys(): + if isinstance(graph.node[n][attr], list): + warning = True + warning_set = {'n:' + attr} | warning_set + graph.node[n][attr] = list_to_scd(graph.node[n][attr]) - def node_merge(self, node1, node2, show_warning=True): + for n1, n2, data in graph.edges(data=True): + for k in data: + if isinstance(data[k], list): + warning = True + warning_set = {'e:'+k} | warning_set + data[k] = list_to_scd(data[k]) + + if warning: + warnings.warn("The provided graph contained the vector attributes: {}. All values of vector attributes have" + " been converted to semicolon-delimited strings. To prevent this, remove vector attributes or" + " convert them to atomic attributes prior to calling .write_graphml" + .format(warning_set)) + nx.write_graphml(graph, fname) + print("Success. Wrote GraphML file {} to {}".format(fname, os.getcwd())) + + def write_tnet(self, fname, mode_string="type", weighted=False, time_string="date", node_index_string="tnet_id", + weight_string='weight'): """ - Combines node1 and node2. After merge, node1 will remain, while node2 will be removed. node2's edges will become - node1 edges, while retaining all their edge attributes. Vector attributes of node1 and node2 whose - identifiers match will be combined, retaining all values. Atomic attributes which exist in only one of the - two nodes will be included in the merge node. Finally, if node1 and node2 contain a conflicting atomic - attribute, node1's value will overwrite node2's value. + A function to write an edgelist formatted for the tnet library for network analysis in R. **Parameters** : - > *node1* : `string` + > *fname* : `string` - >> The identifier for a node. This node's attributes will persist to the merged node. + >> A string indicating the path or file name to write to. - > *node2* : `string` + > *mode_string* : `string` - >> The identifier for a second node. Any non-conflicting attributes will persist to the merged node. + >> The name string of the mode node attribute. - > *show_warning* : `bool` + > *weighted* : `bool` - >> A boolean parameter indicating whether overwrite warnings should be displayed. + >> Do the edges have weights? True or false. - **Return** : `MultiGraphPlus` + > *time_string* : `string` + + >> the name string of the date/time node attribute. + + > *node_index_string* : `int` + + >> Creates a new integer id attribute. + + > *weight_string* : `string` + + >> The name of the weight node attribute. + + **Return** : `None` + + *Source* : + + > Adapted from code written by Reid McIlroy Young for the Metaknowledge python library. + + """ + modes = [] + mode1set = set() + for node_index, node in enumerate(self.nodes_iter(data=True), start=1): + try: + nmode = node[1][mode_string] + except KeyError: + # too many modes so will fail + modes = [1, 2, 3] + nmode = 4 + if nmode not in modes: + if len(modes) < 2: + modes.append(nmode) + else: + raise ValueError( + "Too many modes of '{}' found in the network or one of the nodes was missing its mode. " + "There must be exactly 2 modes.".format(mode_string)) + if nmode == modes[0]: + mode1set.add(node[0]) + node[1][node_index_string] = node_index + if len(modes) != 2: + raise ValueError( + "Too few modes of '{}' found in the network. There must be exactly 2 modes.".format(mode_string)) + with open(fname, 'w', encoding='utf-8') as f: + for n1, n2, eDict in self.edges_iter(data=True): + if n1 in mode1set: + if n2 in mode1set: + raise ValueError( + "The nodes '{}' and '{}' have an edge and the same type. " + "The network must be purely 2-mode.".format(n1, n2)) + elif n2 in mode1set: + n1, n2 = n2, n1 + else: + raise ValueError( + "The nodes '{}' and '{}' have an edge and the same type. " + "The network must be purely 2-mode.".format(n1, n2)) - > a new multigraphplus object which has merged nodes 1 and 2 together into node1, which will also have gained node2's edges. + if time_string is not None and time_string in eDict: + edt = eDict[time_string] + if type(edt) is str: + edt = datetime_git(eDict[time_string]) + e_time_string = edt.strftime("\"%y-%m-%d %H:%M:%S\"") + else: + e_time_string = '' - """ - merged_graph = copy.deepcopy(self) + # Write to file + node1 = self.node[n1][node_index_string] + node2 = self.node[n2][node_index_string] + if time_string is not None: + f.write("{} {} {}".format(e_time_string, node1, node2)) + else: + f.write("{} {}".format(node1, node2)) - # Check: Both node1 and node2 exist in merged_graph - if node1 not in merged_graph.nodes(): - raise MergeError(node1 + " is not a valid node") - if node2 not in merged_graph.nodes(): - raise MergeError(node2 + " is not a valid node") + if weighted: + weight = eDict[weight_string] + f.write(" {}\n".format(weight)) + else: + f.write("\n") + print("Success. Wrote Tnet file {} to {}".format(fname, os.getcwd())) +
      - # Check: node1 and node2's types are the same - if 'type' in merged_graph.node[node1] and 'type' in merged_graph.node[node2]: - if merged_graph.node[node1]['type'] != merged_graph.node[node2]['type']: - raise MergeError("node1 and node2's types do not match") +
      - # Moves all edges from node2 to node1 - for e in merged_graph.edges(node2, data=True): - merged_graph.add_edge(node1, e[1], attr_dict=e[2]) - merged_graph.remove_edge(e[0], e[1]) + - # Adds node2's attributes to node1. There are three cases for this: - # 1. Vector attributes are joined to create one larger vector - # 2. Non-conflicting Atomic attributes are kept and preserved in the final node - # 3. Conflicting Atomic attributes are not added from node2 (node1 values persist) - node_merge_warn = False - node_merge_warn_list = [] +
      - for na in merged_graph.node[node2]: - if na not in merged_graph.node[node1]: # Deals with case 2 - merged_graph.node[node1][na] = merged_graph.node[node2][na] - elif isinstance(merged_graph.node[node2][na], list): # Deals with case 1 - merged_graph.node[node1][na] = merged_graph.node[node1][na] + merged_graph.node[node2][na] - elif merged_graph.node[node1][na] != merged_graph.node[node2][na]: - node_merge_warn = True - node_merge_warn_list.append(na) - merged_graph.remove_node(node2) # Removes node2 +

      Classes

      + +
      +

      class MultiGraphPlus

      + + +
      + +
      +
      class MultiGraphPlus(nx.MultiGraph):
       
      -        if node_merge_warn and show_warning:
      -            print("Note: nodes '{}' and '{}' have the following conflicting atomic attributes: {}. In these cases, "
      -                  "'{}' attribute values have been retained, while '{}' values have been ignored. If you would rather "
      -                  "retain '{}' attributes, set '{}' to node1 and '{}' to node2."
      -                  .format(node1, node2, node_merge_warn_list, node1, node2, node2, node2, node1))
      +    mode1 = ""
       
      -        return merged_graph
      +    mode2 = ""
       
           def collapse_edges(self, sum_weights=False):
               """
      @@ -1624,428 +1708,149 @@ 

      gitnet.multigraph module

      edge_attr[k] = data[k] gnew.add_edge(n1, n2, attr_dict=edge_attr) return gnew -
      - -
      - - - -
      - - -

      Classes

      - -
      -

      class MultiGraphPlus

      - - -

      An undirected graph class that can store multiedges.

      -

      Multiedges are multiple edges between two nodes. Each edge -can hold optional data or attributes.

      -

      A MultiGraph holds undirected edges. Self loops are allowed.

      -

      Nodes can be arbitrary (hashable) Python objects with optional -key/value attributes.

      -

      Edges are represented as links between nodes with optional -key/value attributes.

      -

      Parameters

      -

      data : input graph - Data to initialize graph. If data=None (default) an empty - graph is created. The data can be an edge list, or any - NetworkX graph object. If the corresponding optional Python - packages are installed the data can also be a NumPy matrix - or 2d ndarray, a SciPy sparse matrix, or a PyGraphviz graph.

      -

      attr : keyword arguments, optional (default= no attributes) - Attributes to add to graph as key=value pairs.

      -

      See Also

      -

      Graph -DiGraph -MultiDiGraph

      -

      Examples

      -

      Create an empty graph structure (a "null graph") with no nodes and -no edges.

      -
      -
      -
      -

      G = nx.MultiGraph()

      -
      -
      -
      -

      G can be grown in several ways.

      -

      Nodes:

      -

      Add one node at a time:

      -
      -
      -
      -

      G.add_node(1)

      -
      -
      -
      -

      Add the nodes from any container (a list, dict, set or -even the lines from a file or the nodes from another graph).

      -
      -
      -
      -

      G.add_nodes_from([2,3]) -G.add_nodes_from(range(100,110)) -H=nx.Graph() -H.add_path([0,1,2,3,4,5,6,7,8,9]) -G.add_nodes_from(H)

      -
      -
      -
      -

      In addition to strings and integers any hashable Python object -(except None) can represent a node, e.g. a customized node object, -or even another Graph.

      -
      -
      -
      -

      G.add_node(H)

      -
      -
      -
      -

      Edges:

      -

      G can also be grown by adding edges.

      -

      Add one edge,

      -
      -
      -
      -

      G.add_edge(1, 2)

      -
      -
      -
      -

      a list of edges,

      -
      -
      -
      -

      G.add_edges_from([(1,2),(1,3)])

      -
      -
      -
      -

      or a collection of edges,

      -
      -
      -
      -

      G.add_edges_from(H.edges())

      -
      -
      -
      -

      If some edges connect nodes not yet in the graph, the nodes -are added automatically. If an edge already exists, an additional -edge is created and stored using a key to identify the edge. -By default the key is the lowest unused integer.

      -
      -
      -
      -

      G.add_edges_from([(4,5,dict(route=282)), (4,5,dict(route=37))]) -G[4] -{3: {0: {}}, 5: {0: {}, 1: {'route': 282}, 2: {'route': 37}}}

      -
      -
      -
      -

      Attributes:

      -

      Each graph, node, and edge can hold key/value attribute pairs -in an associated attribute dictionary (the keys must be hashable). -By default these are empty, but can be added or changed using -add_edge, add_node or direct manipulation of the attribute -dictionaries named graph, node and edge respectively.

      -
      -
      -
      -

      G = nx.MultiGraph(day="Friday") -G.graph -{'day': 'Friday'}

      -
      -
      -
      -

      Add node attributes using add_node(), add_nodes_from() or G.node

      -
      -
      -
      -

      G.add_node(1, time='5pm') -G.add_nodes_from([3], time='2pm') -G.node[1] -{'time': '5pm'} -G.node[1]['room'] = 714 -del G.node[1]['room'] # remove attribute -G.nodes(data=True) -[(1, {'time': '5pm'}), (3, {'time': '2pm'})]

      -
      -
      -
      -

      Warning: adding a node to G.node does not add it to the graph.

      -

      Add edge attributes using add_edge(), add_edges_from(), subscript -notation, or G.edge.

      -
      -
      -
      -

      G.add_edge(1, 2, weight=4.7 ) -G.add_edges_from([(3,4),(4,5)], color='red') -G.add_edges_from([(1,2,{'color':'blue'}), (2,3,{'weight':8})]) -G[1][2][0]['weight'] = 4.7 -G.edge[1][2][0]['weight'] = 4

      -
      -
      -
      -

      Shortcuts:

      -

      Many common graph features allow python syntax to speed reporting.

      -
      -
      -
      -

      1 in G # check if node in graph -True -[n for n in G if n<3] # iterate through nodes -[1, 2] -len(G) # number of nodes in graph -5 -G[1] # adjacency dict keyed by neighbor to edge attributes -... # Note: you should not change this dict manually! -{2: {0: {'weight': 4}, 1: {'color': 'blue'}}}

      -
      -
      -
      -

      The fastest way to traverse all edges of a graph is via -adjacency_iter(), but the edges() method is often more convenient.

      -
      -
      -
      -

      for n,nbrsdict in G.adjacency_iter(): -... for nbr,keydict in nbrsdict.items(): -... for key,eattr in keydict.items(): -... if 'weight' in eattr: -... (n,nbr,key,eattr['weight']) -(1, 2, 0, 4) -(2, 1, 0, 4) -(2, 3, 0, 8) -(3, 2, 0, 8) -G.edges(data='weight', keys=True) -[(1, 2, 0, 4), (1, 2, 1, None), (2, 3, 0, 8), (3, 4, 0, None), (4, 5, 0, None)]

      -
      -
      -
      -

      Reporting:

      -

      Simple graph information is obtained using methods. -Iterator versions of many reporting methods exist for efficiency. -Methods exist for reporting nodes(), edges(), neighbors() and degree() -as well as the number of nodes and edges.

      -

      For details on these and other miscellaneous methods, see below.

      -

      Subclasses (Advanced):

      -

      The MultiGraph class uses a dict-of-dict-of-dict-of-dict data structure. -The outer dict (node_dict) holds adjacency lists keyed by node. -The next dict (adjlist) represents the adjacency list and holds -edge_key dicts keyed by neighbor. The edge_key dict holds each edge_attr -dict keyed by edge key. The inner dict (edge_attr) represents -the edge data and holds edge attribute values keyed by attribute names.

      -

      Each of these four dicts in the dict-of-dict-of-dict-of-dict -structure can be replaced by a user defined dict-like object. -In general, the dict-like features should be maintained but -extra features can be added. To replace one of the dicts create -a new graph class by changing the class(!) variable holding the -factory for that dict-like structure. The variable names -are node_dict_factory, adjlist_dict_factory, edge_key_dict_factory -and edge_attr_dict_factory.

      -

      node_dict_factory : function, (default: dict) - Factory function to be used to create the outer-most dict - in the data structure that holds adjacency lists keyed by node. - It should require no arguments and return a dict-like object.

      -

      adjlist_dict_factory : function, (default: dict) - Factory function to be used to create the adjacency list - dict which holds multiedge key dicts keyed by neighbor. - It should require no arguments and return a dict-like object.

      -

      edge_key_dict_factory : function, (default: dict) - Factory function to be used to create the edge key dict - which holds edge data keyed by edge key. - It should require no arguments and return a dict-like object.

      -

      edge_attr_dict_factory : function, (default: dict) - Factory function to be used to create the edge attribute - dict which holds attrbute values keyed by attribute name. - It should require no arguments and return a dict-like object.

      -

      Examples

      -

      Create a multigraph object that tracks the order nodes are added.

      -
      -
      -
      -

      from collections import OrderedDict -class OrderedGraph(nx.MultiGraph): -... node_dict_factory = OrderedDict -G = OrderedGraph() -G.add_nodes_from( (2,1) ) -G.nodes() -[2, 1] -G.add_edges_from( ((2,2), (2,1), (2,1), (1,1)) ) -G.edges() -[(2, 1), (2, 1), (2, 2), (1, 1)]

      -
      -
      -
      -

      Create a multgraph object that tracks the order nodes are added -and for each node track the order that neighbors are added and for -each neighbor tracks the order that multiedges are added.

      -
      -
      -
      -

      class OrderedGraph(nx.MultiGraph): -... node_dict_factory = OrderedDict -... adjlist_dict_factory = OrderedDict -... edge_key_dict_factory = OrderedDict -G = OrderedGraph() -G.add_nodes_from( (2,1) ) -G.nodes() -[2, 1] -G.add_edges_from( ((2,2), (2,1,2,{'weight':0.1}), (2,1,1,{'weight':0.2}), (1,1)) ) -G.edges(keys=True) -[(2, 2, 0), (2, 1, 2), (2, 1, 1), (1, 1, 0)]

      -
      -
      -
      -
      - -
      -
      class MultiGraphPlus(nx.MultiGraph):
      -
      -    mode1 = ""
      -
      -    mode2 = ""
       
      -    def write_graphml(self, fname):
      +    def describe(self, extra=False):
               """
      -        Converts a `MultiGraphPlus` object to a graphml file.
      +        Provides a summary of graph statistics. Includes basic statistics like the number of nodes, edges,
      +        denstiy, and the average degree for one mode. Prints a string that contains each of the items that make up the summary.
      +        Density is calculated using one of the modes of the original bipartite network graph.
       
               **Parameters** :
       
      -        > *fname* :
      +        > *extra* : `bool`
       
      -        >> A string indicating the path or file name to write to. File names which end in `.gz` or `.bz2` will be compressed.
      +        >> Runs the low efficiency algorithms, which can be resource-intensive on large networks.
      +        >> Recommended maximum network size for the low efficiency algorithms is around 100 nodes.
       
      -        **Return** : `None`
      +        **Returns** : `string`
       
      -        > This method will have the side effect of creating a file, specified by fpath.
      -        > This method cannot use vector attributes within the graphml file. Instead, vector attributes are converted into
      -        > a semicolon-delimited string. When this occurs, a warning is raised indicating the vector attributes (node
      -        > attributes are preceded by 'n:' while edge attributes are preceded by 'e:').
      +        > Returns the descriptive string that contains information about the `MultiGraphPlus` object.
       
               """
      +        mode1 = self.mode1
      +        mode2 = self.mode2
      +        density = bipartite.density(self, bipartite.sets(self)[0])
      +        edges = self.number_of_edges()
      +        nodes_mode1 = 0
      +        nodes_mode2 = 0
      +        for n in self.nodes():
      +            if self.node[n]['type'] == mode1:
      +                nodes_mode1 += 1
      +            elif self.node[n]['type'] == mode2:
      +                nodes_mode2 += 1
       
      -        graph = copy.deepcopy(self)
      -
      -        warning = False
      -        warning_set = set([])
      -        for n in graph.nodes():
      -            for attr in graph.node[n].keys():
      -                if isinstance(graph.node[n][attr], list):
      -                    warning = True
      -                    warning_set = {'n:' + attr} | warning_set
      -                    graph.node[n][attr] = list_to_scd(graph.node[n][attr])
      -
      -        for n1, n2, data in graph.edges(data=True):
      -            for k in data:
      -                if isinstance(data[k], list):
      -                    warning = True
      -                    warning_set = {'e:'+k} | warning_set
      -                    data[k] = list_to_scd(data[k])
      -
      -        if warning:
      -            warnings.warn("The provided graph contained the vector attributes: {}. All values of vector attributes have"
      -                          " been converted to semicolon-delimited strings. To prevent this, remove vector attributes or"
      -                          " convert them to atomic attributes prior to calling .write_graphml"
      -                          .format(warning_set))
      +        descriptives_nodes = "This is a bipartite network of types '{}' and '{}'.\n " \
      +                             "{} nodes are of the type '{}'.\n " \
      +                             "{} nodes are of the type '{}'.\n".format(str(mode1), str(mode2), str(nodes_mode1),
      +                                                                       str(mode1), str(nodes_mode2), str(mode2))
      +        descriptives_edges = "There are {} edges.\n".format(str(edges))
      +        descriptives_density = "Density: {}.\n".format(str(density))
      +        descriptives = descriptives_nodes + descriptives_edges + descriptives_density
       
      -        nx.write_graphml(graph, fname)
      +        if extra:
      +            # Note: for each mode of the bipartite graph, degree and betweenness centrality are the same.
      +            # Keeping them both makes it easy to compare them and make sure they are the same.
      +            degree_mode1 = bipartite.degree_centrality(self, bipartite.sets(self)[0])
      +            degree_mode2 = bipartite.degree_centrality(self, bipartite.sets(self)[1])
      +            degree_mode1 = list(degree_mode1.values())
      +            degree_mode2 = list(degree_mode2.values())
      +            degree_mode1 = np.mean(degree_mode1)
      +            degree_mode2 = np.mean(degree_mode2)
      +            betweenness_mode1 = bipartite.betweenness_centrality(self, bipartite.sets(self)[0])
      +            betweenness_mode1 = list(betweenness_mode1.values())
      +            betweenness_mode1 = np.mean(betweenness_mode1)
      +            betweenness_mode2 = bipartite.betweenness_centrality(self, bipartite.sets(self)[1])
      +            betweenness_mode2 = list(betweenness_mode2.values())
      +            betweenness_mode2 = np.mean(betweenness_mode2)
      +            g = nx.Graph(self)
      +            projection = bipartite.projected_graph(g, bipartite.sets(g)[0])
      +            transitivity = nx.transitivity(projection)
      +            descriptives_transitivity = "Transitivity: {}.\n".format(str(transitivity))
      +            descriptives_degree_centrality = "Mean Degree Centrality for '{}': {}.\n" \
      +                                             "Mean Degree Centrality for '{}': {}.\n".format(str(mode1),
      +                                                                                             str(degree_mode1),
      +                                                                                             str(mode2),
      +                                                                                             str(degree_mode2))
      +            descriptives_btwn_centrality = "Mean Betweenness Centrality for '{}': {}.\n"\
      +                                           "Mean Betweenness Centrality for '{}': {}.\n".format(str(mode1),
      +                                                                                                str(betweenness_mode1),
      +                                                                                                str(mode2),
      +                                                                                                str(betweenness_mode2))
      +            descriptives = descriptives + descriptives_transitivity +\
      +                descriptives_degree_centrality + descriptives_btwn_centrality
      +        print(descriptives)
      +        return descriptives
       
      -    def write_tnet(self, fname, mode_string="type", weighted=False, time_string="date", node_index_string="tnet_id",
      -                   weight_string='weight'):
      +    def node_merge(self, node1, node2, show_warning=True):
               """
      -        A function to write an edgelist formatted for the tnet library for network analysis in R.
      +        Combines node1 and node2. After merge, node1 will remain, while node2 will be removed. node2's edges will become
      +        node1 edges, while retaining all their edge attributes. Vector attributes of node1 and node2 whose
      +        identifiers match will be combined, retaining all values. Atomic attributes which exist in only one of the
      +        two nodes will be included in the merge node. Finally, if node1 and node2 contain a conflicting atomic
      +        attribute, node1's value will overwrite node2's value.
       
               **Parameters** :
       
      -        > *fname* : `string`
      -
      -        >> A string indicating the path or file name to write to.
      -
      -        > *mode_string* : `string`
      +        > *node1* : `string`
       
      -        >> The name string of the mode node attribute.
      +        >> The identifier for a node. This node's attributes will persist to the merged node.
       
      -        > *weighted* : `bool`
      +        > *node2* : `string`
       
      -        >> Do the edges have weights? True or false.
      +        >> The identifier for a second node. Any non-conflicting attributes will persist to the merged node.
       
      -        > *time_string* : `string`
      +        > *show_warning* : `bool`
       
      -        >> the name string of the date/time node attribute.
      +        >> A boolean parameter indicating whether overwrite warnings should be displayed.
       
      -        > *node_index_string* : `int`
      +        **Return** : `MultiGraphPlus`
       
      -        >> Creates a new integer id attribute.
      +        > a new multigraphplus object which has merged nodes 1 and 2 together into node1, which will also have gained node2's edges.
       
      -        > *weight_string* : `string`
      +        """
      +        merged_graph = copy.deepcopy(self)
       
      -        >> The name of the weight node attribute.
      +        # Check: Both node1 and node2 exist in merged_graph
      +        if node1 not in merged_graph.nodes():
      +            raise MergeError(node1 + " is not a valid node")
      +        if node2 not in merged_graph.nodes():
      +            raise MergeError(node2 + " is not a valid node")
       
      -        **Return** : `None`
      +        # Check: node1 and node2's types are the same
      +        if 'type' in merged_graph.node[node1] and 'type' in merged_graph.node[node2]:
      +            if merged_graph.node[node1]['type'] != merged_graph.node[node2]['type']:
      +                raise MergeError("node1 and node2's types do not match")
       
      -        *Source* :
      +        # Moves all edges from node2 to node1
      +        for e in merged_graph.edges(node2, data=True):
      +            merged_graph.add_edge(node1, e[1], attr_dict=e[2])
      +            merged_graph.remove_edge(e[0], e[1])
       
      -        > Adapted from code written by Reid McIlroy Young for the Metaknowledge python library.
      +        # Adds node2's attributes to node1. There are three cases for this:
      +            # 1. Vector attributes are joined to create one larger vector
      +            # 2. Non-conflicting Atomic attributes are kept and preserved in the final node
      +            # 3. Conflicting Atomic attributes are not added from node2 (node1 values persist)
      +        node_merge_warn = False
      +        node_merge_warn_list = []
       
      -        """
      -        modes = []
      -        mode1set = set()
      -        for node_index, node in enumerate(self.nodes_iter(data=True), start=1):
      -            try:
      -                nmode = node[1][mode_string]
      -            except KeyError:
      -                # too many modes so will fail
      -                modes = [1, 2, 3]
      -                nmode = 4
      -            if nmode not in modes:
      -                if len(modes) < 2:
      -                    modes.append(nmode)
      -                else:
      -                    raise ValueError(
      -                        "Too many modes of '{}' found in the network or one of the nodes was missing its mode. "
      -                        "There must be exactly 2 modes.".format(mode_string))
      -            if nmode == modes[0]:
      -                mode1set.add(node[0])
      -            node[1][node_index_string] = node_index
      -        if len(modes) != 2:
      -            raise ValueError(
      -                "Too few modes of '{}' found in the network. There must be exactly 2 modes.".format(mode_string))
      -        with open(fname, 'w', encoding='utf-8') as f:
      -            for n1, n2, eDict in self.edges_iter(data=True):
      -                if n1 in mode1set:
      -                    if n2 in mode1set:
      -                        raise ValueError(
      -                            "The nodes '{}' and '{}' have an edge and the same type. "
      -                            "The network must be purely 2-mode.".format(n1, n2))
      -                elif n2 in mode1set:
      -                    n1, n2 = n2, n1
      -                else:
      -                    raise ValueError(
      -                        "The nodes '{}' and '{}' have an edge and the same type. "
      -                        "The network must be purely 2-mode.".format(n1, n2))
      +        for na in merged_graph.node[node2]:
      +            if na not in merged_graph.node[node1]:  # Deals with case 2
      +                merged_graph.node[node1][na] = merged_graph.node[node2][na]
      +            elif isinstance(merged_graph.node[node2][na], list):  # Deals with case 1
      +                merged_graph.node[node1][na] = merged_graph.node[node1][na] + merged_graph.node[node2][na]
      +            elif merged_graph.node[node1][na] != merged_graph.node[node2][na]:
      +                node_merge_warn = True
      +                node_merge_warn_list.append(na)
       
      -                if time_string is not None and time_string in eDict:
      -                    edt = eDict[time_string]
      -                    if type(edt) is str:
      -                        edt = datetime_git(eDict[time_string])
      -                    e_time_string = edt.strftime("\"%y-%m-%d %H:%M:%S\"")
      -                else:
      -                    e_time_string = ''
      +        merged_graph.remove_node(node2)  # Removes node2
       
      -                # Write to file
      -                node1 = self.node[n1][node_index_string]
      -                node2 = self.node[n2][node_index_string]
      -                if time_string is not None:
      -                    f.write("{} {} {}".format(e_time_string, node1, node2))
      -                else:
      -                    f.write("{} {}".format(node1, node2))
      +        if node_merge_warn and show_warning:
      +            print("Note: nodes '{}' and '{}' have the following conflicting atomic attributes: {}. In these cases, "
      +                  "'{}' attribute values have been retained, while '{}' values have been ignored. If you would rather "
      +                  "retain '{}' attributes, set '{}' to node1 and '{}' to node2."
      +                  .format(node1, node2, node_merge_warn_list, node1, node2, node2, node2, node1))
       
      -                if weighted:
      -                    weight = eDict[weight_string]
      -                    f.write(" {}\n".format(weight))
      -                else:
      -                    f.write("\n")
      +        return merged_graph
       
           def node_attributes(self, name, helper):
               """
      @@ -2125,260 +1930,200 @@ 

      Examples

      print("Plotting...") if layout in ["dot", "neato", "fdp", "circo"]: nx.draw(copy_net, - pos=graphviz_layout(copy_net, prog=layout), - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + pos=graphviz_layout(copy_net, prog=layout), + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) if layout == "spring": nx.draw(copy_net, - pos=nx.spring_layout(copy_net, k=k, iterations=iterations), - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + pos=nx.spring_layout(copy_net, k=k, iterations=iterations), + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "circular": nx.draw_circular(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "shell": nx.draw_shell(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "spectral": nx.draw_spectral(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) - elif layout == "random": - nx.draw_random(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) - # Save figure if applicable - if fname is not None: - plt.savefig(fname, bbox_inches="tight") - print("Wrote file: {}".format(fname)) - - def describe(self, extra=False): - """ - Provides a summary of graph statistics. Includes basic statistics like the number of nodes, edges, - denstiy, and the average degree for one mode. Prints a string that contains each of the items that make up the summary. - Density is calculated using one of the modes of the original bipartite network graph. - - **Parameters** : - - > *extra* : `bool` - - >> Runs the low efficiency algorithms, which can be resource-intensive on large networks. - >> Recommended maximum network size for the low efficiency algorithms is around 100 nodes. - - **Returns** : `string` - - > Returns the descriptive string that contains information about the `MultiGraphPlus` object. - - """ - mode1 = self.mode1 - mode2 = self.mode2 - density = bipartite.density(self, bipartite.sets(self)[0]) - edges = self.number_of_edges() - nodes_mode1 = 0 - nodes_mode2 = 0 - for n in self.nodes(): - if self.node[n]['type'] == mode1: - nodes_mode1 += 1 - elif self.node[n]['type'] == mode2: - nodes_mode2 += 1 - - descriptives_nodes = "This is a bipartite network of types '{}' and '{}'.\n " \ - "{} nodes are of the type '{}'.\n " \ - "{} nodes are of the type '{}'.\n".format(str(mode1), str(mode2), str(nodes_mode1), - str(mode1), str(nodes_mode2), str(mode2)) - descriptives_edges = "There are {} edges.\n".format(str(edges)) - descriptives_density = "Density: {}.\n".format(str(density)) - descriptives = descriptives_nodes + descriptives_edges + descriptives_density - - if extra: - # Note: for each mode of the bipartite graph, degree and betweenness centrality are the same. - # Keeping them both makes it easy to compare them and make sure they are the same. - degree_mode1 = bipartite.degree_centrality(self, bipartite.sets(self)[0]) - degree_mode2 = bipartite.degree_centrality(self, bipartite.sets(self)[1]) - degree_mode1 = list(degree_mode1.values()) - degree_mode2 = list(degree_mode2.values()) - degree_mode1 = np.mean(degree_mode1) - degree_mode2 = np.mean(degree_mode2) - betweenness_mode1 = bipartite.betweenness_centrality(self, bipartite.sets(self)[0]) - betweenness_mode1 = list(betweenness_mode1.values()) - betweenness_mode1 = np.mean(betweenness_mode1) - betweenness_mode2 = bipartite.betweenness_centrality(self, bipartite.sets(self)[1]) - betweenness_mode2 = list(betweenness_mode2.values()) - betweenness_mode2 = np.mean(betweenness_mode2) - g = nx.Graph(self) - projection = bipartite.projected_graph(g, bipartite.sets(g)[0]) - transitivity = nx.transitivity(projection) - descriptives_transitivity = "Transitivity: {}.\n".format(str(transitivity)) - descriptives_degree_centrality = "Mean Degree Centrality for '{}': {}.\n" \ - "Mean Degree Centrality for '{}': {}.\n".format(str(mode1), - str(degree_mode1), - str(mode2), - str(degree_mode2)) - descriptives_btwn_centrality = "Mean Betweenness Centrality for '{}': {}.\n"\ - "Mean Betweenness Centrality for '{}': {}.\n".format(str(mode1), - str(betweenness_mode1), - str(mode2), - str(betweenness_mode2)) - descriptives = descriptives + descriptives_transitivity +\ - descriptives_degree_centrality + descriptives_btwn_centrality - print(descriptives) - return descriptives + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) + elif layout == "random": + nx.draw_random(copy_net, + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) + # Save figure if applicable + if fname is not None: + plt.savefig(fname, bbox_inches="tight") + print("Wrote file: {} to {}".format(fname, os.getcwd())) - def node_merge(self, node1, node2, show_warning=True): + def write_graphml(self, fname): """ - Combines node1 and node2. After merge, node1 will remain, while node2 will be removed. node2's edges will become - node1 edges, while retaining all their edge attributes. Vector attributes of node1 and node2 whose - identifiers match will be combined, retaining all values. Atomic attributes which exist in only one of the - two nodes will be included in the merge node. Finally, if node1 and node2 contain a conflicting atomic - attribute, node1's value will overwrite node2's value. + Converts a `MultiGraphPlus` object to a graphml file. **Parameters** : - > *node1* : `string` + > *fname* : - >> The identifier for a node. This node's attributes will persist to the merged node. + >> A string indicating the path or file name to write to. File names which end in `.gz` or `.bz2` will be compressed. - > *node2* : `string` + **Return** : `None` - >> The identifier for a second node. Any non-conflicting attributes will persist to the merged node. + > This method will have the side effect of creating a file, specified by fpath. + > This method cannot use vector attributes within the graphml file. Instead, vector attributes are converted into + > a semicolon-delimited string. When this occurs, a warning is raised indicating the vector attributes (node + > attributes are preceded by 'n:' while edge attributes are preceded by 'e:'). - > *show_warning* : `bool` + """ - >> A boolean parameter indicating whether overwrite warnings should be displayed. + graph = copy.deepcopy(self) - **Return** : `MultiGraphPlus` + warning = False + warning_set = set([]) + for n in graph.nodes(): + for attr in graph.node[n].keys(): + if isinstance(graph.node[n][attr], list): + warning = True + warning_set = {'n:' + attr} | warning_set + graph.node[n][attr] = list_to_scd(graph.node[n][attr]) - > a new multigraphplus object which has merged nodes 1 and 2 together into node1, which will also have gained node2's edges. + for n1, n2, data in graph.edges(data=True): + for k in data: + if isinstance(data[k], list): + warning = True + warning_set = {'e:'+k} | warning_set + data[k] = list_to_scd(data[k]) - """ - merged_graph = copy.deepcopy(self) + if warning: + warnings.warn("The provided graph contained the vector attributes: {}. All values of vector attributes have" + " been converted to semicolon-delimited strings. To prevent this, remove vector attributes or" + " convert them to atomic attributes prior to calling .write_graphml" + .format(warning_set)) + nx.write_graphml(graph, fname) + print("Success. Wrote GraphML file {} to {}".format(fname, os.getcwd())) - # Check: Both node1 and node2 exist in merged_graph - if node1 not in merged_graph.nodes(): - raise MergeError(node1 + " is not a valid node") - if node2 not in merged_graph.nodes(): - raise MergeError(node2 + " is not a valid node") + def write_tnet(self, fname, mode_string="type", weighted=False, time_string="date", node_index_string="tnet_id", + weight_string='weight'): + """ + A function to write an edgelist formatted for the tnet library for network analysis in R. - # Check: node1 and node2's types are the same - if 'type' in merged_graph.node[node1] and 'type' in merged_graph.node[node2]: - if merged_graph.node[node1]['type'] != merged_graph.node[node2]['type']: - raise MergeError("node1 and node2's types do not match") + **Parameters** : - # Moves all edges from node2 to node1 - for e in merged_graph.edges(node2, data=True): - merged_graph.add_edge(node1, e[1], attr_dict=e[2]) - merged_graph.remove_edge(e[0], e[1]) + > *fname* : `string` - # Adds node2's attributes to node1. There are three cases for this: - # 1. Vector attributes are joined to create one larger vector - # 2. Non-conflicting Atomic attributes are kept and preserved in the final node - # 3. Conflicting Atomic attributes are not added from node2 (node1 values persist) - node_merge_warn = False - node_merge_warn_list = [] + >> A string indicating the path or file name to write to. - for na in merged_graph.node[node2]: - if na not in merged_graph.node[node1]: # Deals with case 2 - merged_graph.node[node1][na] = merged_graph.node[node2][na] - elif isinstance(merged_graph.node[node2][na], list): # Deals with case 1 - merged_graph.node[node1][na] = merged_graph.node[node1][na] + merged_graph.node[node2][na] - elif merged_graph.node[node1][na] != merged_graph.node[node2][na]: - node_merge_warn = True - node_merge_warn_list.append(na) + > *mode_string* : `string` - merged_graph.remove_node(node2) # Removes node2 + >> The name string of the mode node attribute. - if node_merge_warn and show_warning: - print("Note: nodes '{}' and '{}' have the following conflicting atomic attributes: {}. In these cases, " - "'{}' attribute values have been retained, while '{}' values have been ignored. If you would rather " - "retain '{}' attributes, set '{}' to node1 and '{}' to node2." - .format(node1, node2, node_merge_warn_list, node1, node2, node2, node2, node1)) + > *weighted* : `bool` - return merged_graph + >> Do the edges have weights? True or false. - def collapse_edges(self, sum_weights=False): - """ - Collapses all edges which share nodes into one edge, with a new weight assigned to it. How this weight is - assigned depends on the `sum_weights` parameter. + > *time_string* : `string` - **Parameters** : + >> the name string of the date/time node attribute. - > *sum_weights* : `bool` + > *node_index_string* : `int` - >> An optional boolean parameter. Determines how weights will be assigned to the final edges. - >> If False, the weight will be the number of edges which were collapsed. If True, the weight will be the sum of - >> the weights of collapsed edges. + >> Creates a new integer id attribute. - **Return** : + > *weight_string* : `string` - > A new MultiGraphPlus object, which has collapsed all duplicate edges, assigned a new weight, and - > stores other edge data in lists. + >> The name of the weight node attribute. - **Note** : + **Return** : `None` - > The default weight of an edge is 1. Thus, if sum_weights is set to True, but an edge does not have a - > weight attribute, this method assumes the weight of the edge is 1. + *Source* : + + > Adapted from code written by Reid McIlroy Young for the Metaknowledge python library. """ - gnew = MultiGraphPlus() - for n1, n2, data in self.edges(data=True): - if gnew.has_edge(n1, n2): - gnew_data = gnew.edge[n1][n2][0] - if 'weight' not in data: - gnew_data['weight'] += 1 - for k in data: - if k in gnew_data: - if k == 'weight': - if sum_weights: - gnew_data[k] += data[k] - else: - gnew_data[k] += 1 - elif isinstance(data[k], list): - gnew_data[k] += data[k] - else: - if isinstance(gnew_data[k], list): - gnew_data[k] += [data[k]] - else: - gnew_data[k] = [gnew_data[k], data[k]] - else: - gnew_data[k] = data[k] - else: - edge_attr = {'weight': 1} - for k in data: - if k == 'weight': - if sum_weights: - edge_attr[k] = data[k] - elif isinstance(data[k], list): - edge_attr[k] = data[k] - else: - edge_attr[k] = data[k] - gnew.add_edge(n1, n2, attr_dict=edge_attr) - return gnew + modes = [] + mode1set = set() + for node_index, node in enumerate(self.nodes_iter(data=True), start=1): + try: + nmode = node[1][mode_string] + except KeyError: + # too many modes so will fail + modes = [1, 2, 3] + nmode = 4 + if nmode not in modes: + if len(modes) < 2: + modes.append(nmode) + else: + raise ValueError( + "Too many modes of '{}' found in the network or one of the nodes was missing its mode. " + "There must be exactly 2 modes.".format(mode_string)) + if nmode == modes[0]: + mode1set.add(node[0]) + node[1][node_index_string] = node_index + if len(modes) != 2: + raise ValueError( + "Too few modes of '{}' found in the network. There must be exactly 2 modes.".format(mode_string)) + with open(fname, 'w', encoding='utf-8') as f: + for n1, n2, eDict in self.edges_iter(data=True): + if n1 in mode1set: + if n2 in mode1set: + raise ValueError( + "The nodes '{}' and '{}' have an edge and the same type. " + "The network must be purely 2-mode.".format(n1, n2)) + elif n2 in mode1set: + n1, n2 = n2, n1 + else: + raise ValueError( + "The nodes '{}' and '{}' have an edge and the same type. " + "The network must be purely 2-mode.".format(n1, n2)) + + if time_string is not None and time_string in eDict: + edt = eDict[time_string] + if type(edt) is str: + edt = datetime_git(eDict[time_string]) + e_time_string = edt.strftime("\"%y-%m-%d %H:%M:%S\"") + else: + e_time_string = '' + + # Write to file + node1 = self.node[n1][node_index_string] + node2 = self.node[n2][node_index_string] + if time_string is not None: + f.write("{} {} {}".format(e_time_string, node1, node2)) + else: + f.write("{} {}".format(node1, node2)) + + if weighted: + weight = eDict[weight_string] + f.write(" {}\n".format(weight)) + else: + f.write("\n") + print("Success. Wrote Tnet file {} to {}".format(fname, os.getcwd()))
      @@ -2464,41 +2209,6 @@

      Static methods

      -

      Initialize a graph with edges, name, graph attributes.

      -

      Parameters

      -

      data : input graph - Data to initialize graph. If data=None (default) an empty - graph is created. The data can be an edge list, or any - NetworkX graph object. If the corresponding optional Python - packages are installed the data can also be a NumPy matrix - or 2d ndarray, a SciPy sparse matrix, or a PyGraphviz graph. -name : string, optional (default='') - An optional name for the graph. -attr : keyword arguments, optional (default= no attributes) - Attributes to add to graph as key=value pairs.

      -

      See Also

      -

      convert

      -

      Examples

      -
      -
      -
      -

      G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc -G = nx.Graph(name='my graph') -e = [(1,2),(2,3),(3,4)] # list of edges -G = nx.Graph(e)

      -
      -
      -
      -

      Arbitrary graph attribute pairs (key=value) may be assigned

      -
      -
      -
      -

      G=nx.Graph(e, day="Friday") -G.graph -{'day': 'Friday'}

      -
      -
      -
      @@ -5353,58 +5063,58 @@

      See Also

      print("Plotting...") if layout in ["dot", "neato", "fdp", "circo"]: nx.draw(copy_net, - pos=graphviz_layout(copy_net, prog=layout), - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + pos=graphviz_layout(copy_net, prog=layout), + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) if layout == "spring": nx.draw(copy_net, - pos=nx.spring_layout(copy_net, k=k, iterations=iterations), - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + pos=nx.spring_layout(copy_net, k=k, iterations=iterations), + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "circular": nx.draw_circular(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "shell": nx.draw_shell(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "spectral": nx.draw_spectral(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) elif layout == "random": nx.draw_random(copy_net, - node_size=size, - font_size=5, - node_color=colour_list, - linewidths=.5, - edge_color="DarkGray", - width=.1) + node_size=size, + font_size=5, + node_color=colour_list, + linewidths=.5, + edge_color="DarkGray", + width=.1) # Save figure if applicable if fname is not None: plt.savefig(fname, bbox_inches="tight") - print("Wrote file: {}".format(fname)) + print("Wrote file: {} to {}".format(fname, os.getcwd()))
      @@ -6320,6 +6030,7 @@

      Examples

      " convert them to atomic attributes prior to calling .write_graphml" .format(warning_set)) nx.write_graphml(graph, fname) + print("Success. Wrote GraphML file {} to {}".format(fname, os.getcwd()))
      @@ -6447,6 +6158,7 @@

      Examples

      f.write(" {}\n".format(weight)) else: f.write("\n") + print("Success. Wrote Tnet file {} to {}".format(fname, os.getcwd()))
      diff --git a/gitnet/log.py b/gitnet/log.py index 175670c..d5f7e24 100644 --- a/gitnet/log.py +++ b/gitnet/log.py @@ -14,11 +14,11 @@ # If not, see . # ********************************************************************************************* -import pandas as pd -import datetime as dt import os -import warnings import copy +import warnings +import pandas as pd +import datetime as dt import subprocess as sub from gitnet.multigraph import MultiGraphPlus from gitnet.helpers import datetime_git, filter_before, filter_beforex, filter_since, filter_sincex, \ @@ -916,11 +916,11 @@ def write_edges(self, fname, mode1, mode2, helper=net_edges_simple, edge_attribu Currently, two edge_helper functions are available in gitnet.gn_helpers: - > `simple_edge` + > `net_edges_simple` >> Creates an unweighted edge, and saves the attributes specified by edge_attributes. - > `changes_edge` + > `net_edges_changes` >> Only to be used for Author/File networks, with "changes" from "git log --stat" logs (as in a CommitLog). From 418efd48226d955094e792b7d422ef85615ca4ee Mon Sep 17 00:00:00 2001 From: John McLevey Date: Sun, 2 Feb 2020 10:39:43 -0330 Subject: [PATCH 10/14] Update and rename README.rst to README.md --- README.rst => README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) rename README.rst => README.md (92%) diff --git a/README.rst b/README.md similarity index 92% rename from README.rst rename to README.md index 0bb8c60..5c33b26 100644 --- a/README.rst +++ b/README.md @@ -1,11 +1,10 @@ -Overview -============ + -``gitnet`` is a Python 3 package with tools for collecting, cleaning, and exporting datasets from local Git repositories, as well as creating network datasets and visualizations. The primary purpose of ``gitnet`` is to provide scholarly tools to study the collaboration structure of free and open source software development projects, but may also be of use to organizations, project managers, and curious coders. +# gitnet -``gitnet`` is currently in active development by the University of Waterloo's NetLab_. The current build offers flexible tools for working with local Git repositories. Future iterations will include support for creating networks using issue report and pull request data, tools for analyzing contributors' communication networks, reproducible data collection, and more tools for increased flexibility. If you are curious about the project, want tips regarding how to use ``gitnet``, find a bug, or wish to request a feature, please feel free to email a contributor or submit an issue report. +``gitnet`` is a Python 3 package with tools for collecting, cleaning, and exporting datasets from local Git repositories, as well as creating network datasets and visualizations. The primary purpose of ``gitnet`` is to provide scholarly tools to study the collaboration structure of free and open source software development projects, but may also be of use to organizations, project managers, and curious coders. -.. _NetLab: http://networkslab.org/ +We are not currently developing `gitnet`, but are happy to respond to any questions. A Quick (Meta) Example ------------------------------- From 6386941ac564c349daf08f2fd59bf3eddd079790 Mon Sep 17 00:00:00 2001 From: John McLevey Date: Sun, 2 Feb 2020 10:40:53 -0330 Subject: [PATCH 11/14] Update and rename README.md to README.rst --- README.md => README.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) rename README.md => README.rst (96%) diff --git a/README.md b/README.rst similarity index 96% rename from README.md rename to README.rst index 5c33b26..f759095 100644 --- a/README.md +++ b/README.rst @@ -1,4 +1,10 @@ - + + +.. raw:: html + + + + # gitnet From 211239e13cc898bc35d83f24470814a785cad10f Mon Sep 17 00:00:00 2001 From: John McLevey Date: Sun, 2 Feb 2020 10:41:10 -0330 Subject: [PATCH 12/14] Update README.rst --- README.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.rst b/README.rst index f759095..9931c89 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,3 @@ - - .. raw:: html From e3aa5091c26c707fc34952c940299b25cac9caa7 Mon Sep 17 00:00:00 2001 From: John McLevey Date: Sun, 2 Feb 2020 10:41:31 -0330 Subject: [PATCH 13/14] Update README.rst --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 9931c89..1cb6ee0 100644 --- a/README.rst +++ b/README.rst @@ -4,11 +4,12 @@ -# gitnet +gitnet +======= ``gitnet`` is a Python 3 package with tools for collecting, cleaning, and exporting datasets from local Git repositories, as well as creating network datasets and visualizations. The primary purpose of ``gitnet`` is to provide scholarly tools to study the collaboration structure of free and open source software development projects, but may also be of use to organizations, project managers, and curious coders. -We are not currently developing `gitnet`, but are happy to respond to any questions. +**We are not currently developing `gitnet`**, but are happy to respond to any questions. A Quick (Meta) Example ------------------------------- From 49d059a88f3e74f84fc062a2a018e809cd2d1cf5 Mon Sep 17 00:00:00 2001 From: John McLevey Date: Sun, 2 Feb 2020 10:42:08 -0330 Subject: [PATCH 14/14] Update README.rst --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 1cb6ee0..9e9c45e 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ gitnet ``gitnet`` is a Python 3 package with tools for collecting, cleaning, and exporting datasets from local Git repositories, as well as creating network datasets and visualizations. The primary purpose of ``gitnet`` is to provide scholarly tools to study the collaboration structure of free and open source software development projects, but may also be of use to organizations, project managers, and curious coders. -**We are not currently developing `gitnet`**, but are happy to respond to any questions. +`gitnet` is not under active development right now, but we are happy to respond to any questions you might have about using it. A Quick (Meta) Example -------------------------------